1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
13 // ranges::greater_equal
17 #include <type_traits>
20 #include "test_macros.h"
21 #include "compare_types.h"
23 #include "pointer_comparison_test_helper.h"
25 struct NotTotallyOrdered
{
26 friend bool operator<(const NotTotallyOrdered
&, const NotTotallyOrdered
&);
29 static_assert(!std::is_invocable_v
<std::ranges::greater_equal
, NotTotallyOrdered
, NotTotallyOrdered
>);
30 static_assert(!std::is_invocable_v
<std::ranges::greater_equal
, int, MoveOnly
>);
31 static_assert(std::is_invocable_v
<std::ranges::greater_equal
, explicit_operators
, explicit_operators
>);
33 static_assert(requires
{ typename
std::ranges::greater_equal::is_transparent
; });
35 constexpr bool test() {
36 auto fn
= std::ranges::greater_equal();
38 assert(fn(MoveOnly(42), MoveOnly(42)));
40 ForwardingTestObject a
;
41 ForwardingTestObject b
;
43 assert(!fn(std::move(a
), std::move(b
)));
54 int main(int, char**) {
57 static_assert(test());
59 // test total ordering of int* for greater_equal<int*> and greater_equal<void>.
60 do_pointer_comparison_test(std::ranges::greater_equal());