libstdc++: Deprecate std::rel_ops namespace for C++20

This is deprecated in the C++20 standard and will be removed at some
point.

libstdc++-v3/ChangeLog:

	* include/bits/stl_relops.h (rel_ops): Add deprecated attribute.
	* testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc:
	Add dg-warning for -Wdeprecated warnings.
	* testsuite/20_util/rel_ops.cc: Likewise.
	* testsuite/util/testsuite_containers.h: Disable -Wdeprecated
	warnings when using rel_ops.
This commit is contained in:
Jonathan Wakely 2024-11-27 23:36:03 +00:00 committed by Jonathan Wakely
parent 3f3966b5a3
commit bb551f497e
No known key found for this signature in database
4 changed files with 12 additions and 3 deletions

View file

@ -63,7 +63,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace rel_ops
namespace rel_ops _GLIBCXX20_DEPRECATED_SUGGEST("<=>")
{
/** @namespace std::rel_ops
* @brief The generated relational operators are sequestered here.

View file

@ -21,5 +21,5 @@
namespace gnu
{
using namespace std::rel_ops;
using namespace std::rel_ops; // { dg-warning "deprecated" "" { target c++20 } }
}

View file

@ -24,7 +24,7 @@
#include <utility>
#include <vector>
using namespace std::rel_ops;
using namespace std::rel_ops; // { dg-warning "deprecated" "" { target c++20 } }
// libstdc++/3628
void test01()

View file

@ -183,9 +183,12 @@ namespace __gnu_test
{
forward_members_unordered(const typename _Tp::value_type& v)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
// Make sure that even if rel_ops is injected there is no ambiguity
// when comparing iterators.
using namespace std::rel_ops;
#pragma GCC diagnostic pop
typedef _Tp test_type;
test_type container;
@ -283,9 +286,12 @@ namespace __gnu_test
{
forward_members(_Tp& container)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
// Make sure that even if rel_ops is injected there is no ambiguity
// when comparing iterators.
using namespace std::rel_ops;
#pragma GCC diagnostic pop
typedef traits<_Tp> traits_type;
iterator_concept_checks<typename _Tp::iterator,
@ -318,9 +324,12 @@ namespace __gnu_test
category_members(_Tp& container)
: forward_members<_Tp>(container)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
// Make sure that even if rel_ops is injected there is no ambiguity
// when comparing iterators.
using namespace std::rel_ops;
#pragma GCC diagnostic pop
assert( !(container.begin() < container.begin()) );
assert( !(container.cbegin() < container.cbegin()) );