xref: /freebsd/contrib/llvm-project/libcxx/include/__concepts/equality_comparable.h (revision 3078531de10dcae44b253a35125c949ff4235284)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H
10 #define _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H
11 
12 #include <__concepts/boolean_testable.h>
13 #include <__concepts/common_reference_with.h>
14 #include <__config>
15 #include <type_traits>
16 
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 #pragma GCC system_header
19 #endif
20 
21 _LIBCPP_BEGIN_NAMESPACE_STD
22 
23 #if !defined(_LIBCPP_HAS_NO_CONCEPTS)
24 
25 // [concept.equalitycomparable]
26 
27 template<class _Tp, class _Up>
28 concept __weakly_equality_comparable_with =
29   requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
30     { __t == __u } -> __boolean_testable;
31     { __t != __u } -> __boolean_testable;
32     { __u == __t } -> __boolean_testable;
33     { __u != __t } -> __boolean_testable;
34   };
35 
36 template<class _Tp>
37 concept equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>;
38 
39 template<class _Tp, class _Up>
40 concept equality_comparable_with =
41   equality_comparable<_Tp> && equality_comparable<_Up> &&
42   common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> &&
43   equality_comparable<
44     common_reference_t<
45       __make_const_lvalue_ref<_Tp>,
46       __make_const_lvalue_ref<_Up>>> &&
47   __weakly_equality_comparable_with<_Tp, _Up>;
48 
49 #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
50 
51 _LIBCPP_END_NAMESPACE_STD
52 
53 #endif // _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H
54