]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/variant2/test/variant_move_construct_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>
12 using namespace boost::variant2
;
18 constexpr X( int v
): v( v
) {}
19 constexpr operator int() const { return v
; }
26 constexpr Y( int v
): v( v
) {}
27 constexpr operator int() const { return v
; }
35 #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
37 template<class T
, class V
> constexpr T
test( V
&& v
)
39 V
v2( std::forward
<V
>(v
) );
46 constexpr auto w
= test
<int>( variant
<int>( 1 ) );
47 STATIC_ASSERT( w
== 1 );
51 constexpr auto w
= test
<X
>( variant
<X
>( 1 ) );
52 STATIC_ASSERT( w
== 1 );
55 #if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000
59 constexpr auto w
= test
<Y
>( variant
<Y
>( 1 ) );
60 STATIC_ASSERT( w
== 1 );
66 constexpr auto w
= test
<int>( variant
<int, float>( 1 ) );
67 STATIC_ASSERT( w
== 1 );
71 constexpr auto w
= test
<float>( variant
<int, float>( 3.0f
) );
72 STATIC_ASSERT( w
== 3.0f
);
76 constexpr auto w
= test
<float>( variant
<int, int, float>( 3.0f
) );
77 STATIC_ASSERT( w
== 3.0f
);
81 constexpr auto w
= test
<X
>( variant
<E
, E
, X
>( 1 ) );
82 STATIC_ASSERT( w
== 1 );
86 constexpr auto w
= test
<X
>( variant
<int, int, float, float, X
>( X(1) ) );
87 STATIC_ASSERT( w
== 1 );
90 #if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000
94 constexpr auto w
= test
<Y
>( variant
<E
, E
, Y
>( 1 ) );
95 STATIC_ASSERT( w
== 1 );
99 constexpr auto w
= test
<Y
>( variant
<int, int, float, float, Y
>( Y(1) ) );
100 STATIC_ASSERT( w
== 1 );