]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/variant2/test/variant_value_assign_cx.cpp
2 // Copyright 2017 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>
11 using namespace boost::variant2
;
17 constexpr X( int v
): v( v
) {}
18 constexpr operator int() const { return v
; }
25 constexpr Y( int v
): v( v
) {}
26 constexpr operator int() const { return v
; }
34 #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
36 template<class V
, class T
, class A
> constexpr A
test( A
const& a
)
48 constexpr auto w
= test
<variant
<int>, int>( 1 );
49 STATIC_ASSERT( w
== 1 );
53 constexpr auto w
= test
<variant
<X
>, X
>( 1 );
54 STATIC_ASSERT( w
== 1 );
57 #if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000
61 constexpr auto w
= test
<variant
<Y
>, Y
>( 1 );
62 STATIC_ASSERT( w
== 1 );
68 constexpr auto w
= test
<variant
<int, float>, int>( 1 );
69 STATIC_ASSERT( w
== 1 );
73 constexpr auto w
= test
<variant
<int, float>, float>( 3.0f
);
74 STATIC_ASSERT( w
== 3.0f
);
78 constexpr auto w
= test
<variant
<int, int, float>, float>( 3.0f
);
79 STATIC_ASSERT( w
== 3.0f
);
83 constexpr auto w
= test
<variant
<E
, E
, X
>, X
>( 1 );
84 STATIC_ASSERT( w
== 1 );
88 constexpr auto w
= test
<variant
<int, int, float, float, X
>, X
>( X(1) );
89 STATIC_ASSERT( w
== 1 );
92 #if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000
96 constexpr auto w
= test
<variant
<E
, E
, Y
>, Y
>( 1 );
97 STATIC_ASSERT( w
== 1 );
101 constexpr auto w
= test
<variant
<int, int, float, float, Y
>, Y
>( Y(1) );
102 STATIC_ASSERT( w
== 1 );