| 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 |
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS |
| 10 |
|
| 11 |
// <functional> |
| 12 |
|
| 13 |
// greater_equal |
| 14 |
|
| 15 |
#include <functional> |
| 16 |
#include <type_traits> |
| 17 |
#include <cassert> |
| 18 |
|
| 19 |
#include "test_macros.h" |
| 20 |
#include "pointer_comparison_test_helper.h" |
| 21 |
|
| 22 |
int main(int, char**) |
| 23 |
{ |
| 24 |
typedef std::greater_equal<int> F; |
| 25 |
const F f = F(); |
| 26 |
#if TEST_STD_VER <= 17 |
| 27 |
static_assert((std::is_same<int, F::first_argument_type>::value), "" ); |
| 28 |
static_assert((std::is_same<int, F::second_argument_type>::value), "" ); |
| 29 |
static_assert((std::is_same<bool, F::result_type>::value), "" ); |
| 30 |
#endif |
| 31 |
assert(f(36, 36)); |
| 32 |
assert(f(36, 6)); |
| 33 |
assert(!f(6, 36)); |
| 34 |
{ |
| 35 |
// test total ordering of int* for greater_equal<int*> and |
| 36 |
// greater_equal<void>. |
| 37 |
do_pointer_comparison_test<std::greater_equal>(); |
| 38 |
} |
| 39 |
#if TEST_STD_VER > 11 |
| 40 |
typedef std::greater_equal<> F2; |
| 41 |
const F2 f2 = F2(); |
| 42 |
assert(f2(36, 36)); |
| 43 |
assert(f2(36, 6)); |
| 44 |
assert(!f2(6, 36)); |
| 45 |
assert( f2(36, 6.0)); |
| 46 |
assert( f2(36.0, 6)); |
| 47 |
assert(!f2(6, 36.0)); |
| 48 |
assert(!f2(6.0, 36)); |
| 49 |
|
| 50 |
constexpr bool foo = std::greater_equal<int> () (36, 36); |
| 51 |
static_assert ( foo, "" ); |
| 52 |
|
| 53 |
constexpr bool bar = std::greater_equal<> () (36.0, 36); |
| 54 |
static_assert ( bar, "" ); |
| 55 |
#endif |
| 56 |
|
| 57 |
return 0; |
| 58 |
} |