2021-07-01 09:25:35 -04:00
|
|
|
// -*- C++ -*-
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
|
|
|
|
#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
|
|
|
|
|
|
|
|
#include <__config>
|
2022-02-04 13:09:30 -05:00
|
|
|
#include <__utility/forward.h>
|
2021-07-01 09:25:35 -04:00
|
|
|
#include <concepts>
|
|
|
|
|
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2022-02-01 20:16:40 -05:00
|
|
|
# pragma GCC system_header
|
2021-07-01 09:25:35 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
|
2022-03-12 10:46:57 -05:00
|
|
|
#if _LIBCPP_STD_VER > 17
|
[libc++] Guard much of std::ranges under _LIBCPP_HAS_NO_INCOMPLETE_RANGES.
The logic here is that we are disabling *only* things in `std::ranges::`.
Everything in `std::` is permitted, including `default_sentinel`, `contiguous_iterator`,
`common_iterator`, `projected`, `swappable`, and so on. Then, we include
anything from `std::ranges::` that is required in order to make those things
work: `ranges::swap`, `ranges::swap_ranges`, `input_range`, `ranges::begin`,
`ranges::iter_move`, and so on. But then that's all. Everything else (including
notably all of the "views" and the `std::views` namespace itself) is still
locked up behind `_LIBCPP_HAS_NO_INCOMPLETE_RANGES`.
Differential Revision: https://reviews.llvm.org/D118736
2022-02-01 16:52:02 -05:00
|
|
|
|
2021-07-01 09:25:35 -04:00
|
|
|
namespace ranges {
|
|
|
|
|
|
|
|
struct equal_to {
|
|
|
|
template <class _Tp, class _Up>
|
|
|
|
requires equality_comparable_with<_Tp, _Up>
|
|
|
|
[[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
|
|
|
|
noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)))) {
|
|
|
|
return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u);
|
|
|
|
}
|
|
|
|
|
|
|
|
using is_transparent = void;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct not_equal_to {
|
|
|
|
template <class _Tp, class _Up>
|
|
|
|
requires equality_comparable_with<_Tp, _Up>
|
|
|
|
[[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
|
|
|
|
noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u))))) {
|
|
|
|
return !(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u));
|
|
|
|
}
|
|
|
|
|
|
|
|
using is_transparent = void;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct less {
|
|
|
|
template <class _Tp, class _Up>
|
|
|
|
requires totally_ordered_with<_Tp, _Up>
|
|
|
|
[[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
|
|
|
|
noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)))) {
|
|
|
|
return _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u);
|
|
|
|
}
|
|
|
|
|
|
|
|
using is_transparent = void;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct less_equal {
|
|
|
|
template <class _Tp, class _Up>
|
|
|
|
requires totally_ordered_with<_Tp, _Up>
|
|
|
|
[[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
|
|
|
|
noexcept(noexcept(bool(!(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t))))) {
|
|
|
|
return !(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t));
|
|
|
|
}
|
|
|
|
|
|
|
|
using is_transparent = void;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct greater {
|
|
|
|
template <class _Tp, class _Up>
|
|
|
|
requires totally_ordered_with<_Tp, _Up>
|
|
|
|
[[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
|
|
|
|
noexcept(noexcept(bool(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)))) {
|
|
|
|
return _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t);
|
|
|
|
}
|
|
|
|
|
|
|
|
using is_transparent = void;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct greater_equal {
|
|
|
|
template <class _Tp, class _Up>
|
|
|
|
requires totally_ordered_with<_Tp, _Up>
|
|
|
|
[[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
|
|
|
|
noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u))))) {
|
|
|
|
return !(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u));
|
|
|
|
}
|
|
|
|
|
|
|
|
using is_transparent = void;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ranges
|
2022-02-18 11:36:59 -05:00
|
|
|
|
2022-03-12 10:46:57 -05:00
|
|
|
#endif // _LIBCPP_STD_VER > 17
|
2021-07-01 09:25:35 -04:00
|
|
|
|
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
|
|
|
|
#endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
|