Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Deprecates rel_ops. #91642

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libcxx/docs/ReleaseNotes/19.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ Deprecations and Removals
of randomness, and others. Users that were checking whether including a header would fail (e.g. via a script
or CMake's ``try_compile`` will experience a change in behavior).

- The operators in the ``rel_ops`` namespace have been deprecated. The deprecation is part of the paper
P0768R1 "Library Support for the Spaceship (Comparison) Operator".

Upcoming Deprecations and Removals
----------------------------------
Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/__utility/rel_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace rel_ops {

template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const _Tp& __y) {
inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const _Tp& __y) {
return !(__x == __y);
}

template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI bool operator>(const _Tp& __x, const _Tp& __y) {
inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator>(const _Tp& __x, const _Tp& __y) {
return __y < __x;
}

template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const _Tp& __x, const _Tp& __y) {
inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator<=(const _Tp& __x, const _Tp& __y) {
return !(__y < __x);
}

template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const _Tp& __x, const _Tp& __y) {
inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator>=(const _Tp& __x, const _Tp& __y) {
return !(__x < __y);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// <utility>

// UNSUPPORTED: c++03, c++11, c++14, c++17

#include <utility>
#include <cassert>

struct A {
int data_ = 0;
};

inline bool operator==(const A& x, const A& y) { return x.data_ == y.data_; }

inline bool operator<(const A& x, const A& y) { return x.data_ < y.data_; }

void test() {
using namespace std::rel_ops;
A a1{1};
A a2{2};
(void)(a1 == a1);
(void)(a1 != a2); // note not deprecated message, due to compiler generated operator.
std::rel_ops::operator!=(a1, a2); // expected-warning {{is deprecated}}
(void)(a1 < a2);
(void)(a1 > a2); // expected-warning 2 {{is deprecated}}
(void)(a1 <= a2); // expected-warning 2 {{is deprecated}}
(void)(a1 >= a2); // expected-warning 2 {{is deprecated}}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

// XFAIL: availability-filesystem-missing

// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS

// Make sure the various containers' iterators are not broken by the use of `std::rel_ops`.

#include <utility> // for std::rel_ops
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

// test rel_ops

// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS

#include <utility>
#include <cassert>

Expand Down
Loading