]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/variant2/test/variant_lt_gt_cx.cpp
2 // Copyright 2017, 2019 Peter Dimov
4 // Distributed under the Boost Software License, Version 1.0.
6 // See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt
9 #include <boost/variant2/variant.hpp>
10 using namespace boost::variant2
;
12 #if !defined(BOOST_MP11_HAS_CXX14_CONSTEXPR)
14 #include <boost/config/pragma_message.hpp>
16 BOOST_PRAGMA_MESSAGE("Skipping constexpr op<, op<= test because BOOST_MP11_HAS_CXX14_CONSTEXPR is not defined")
26 inline constexpr bool operator<( X
const&, X
const& ) { return false; }
27 inline constexpr bool operator>( X
const&, X
const& ) { return false; }
28 inline constexpr bool operator<=( X
const&, X
const& ) { return false; }
29 inline constexpr bool operator>=( X
const&, X
const& ) { return false; }
31 #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
33 #define TEST_EQ( v1, v2 ) \
34 STATIC_ASSERT( !(v1 < v2) ); \
35 STATIC_ASSERT( !(v1 > v2) ); \
36 STATIC_ASSERT( v1 <= v2 ); \
37 STATIC_ASSERT( v1 >= v2 );
39 #define TEST_LE( v1, v3 ) \
40 STATIC_ASSERT( v1 < v3 ); \
41 STATIC_ASSERT( v3 > v1 ); \
42 STATIC_ASSERT( !(v1 > v3) ); \
43 STATIC_ASSERT( !(v3 < v1) ); \
44 STATIC_ASSERT( v1 <= v3 ); \
45 STATIC_ASSERT( v3 >= v1 ); \
46 STATIC_ASSERT( !(v1 >= v3) ); \
47 STATIC_ASSERT( !(v3 <= v1) );
52 constexpr variant
<int> v1
, v2
, v3( 1 ), v4( 1 );
60 constexpr variant
<int, float> v1
, v2
, v3( 1 ), v4( 1 ), v5( 3.14f
), v6( 3.14f
);
71 constexpr variant
<int, int, float> v1
, v2
, v3( in_place_index_t
<1>{} ), v4( in_place_index_t
<1>{} ), v5( 3.14f
), v6( 3.14f
);
82 constexpr variant
<X
> v1
, v2
;
84 STATIC_ASSERT( !(v1
< v2
) );
85 STATIC_ASSERT( !(v1
> v2
) );
86 STATIC_ASSERT( !(v1
<= v2
) );
87 STATIC_ASSERT( !(v1
>= v2
) );