• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 Peter Dimov.
2 // Distributed under the Boost Software License, Version 1.0.
3 // https://www.boost.org/LICENSE_1_0.txt
4 
5 #if defined(_MSC_VER) && _MSC_VER < 1910
6 # pragma warning(disable: 4503) // decorated name length exceeded
7 #endif
8 
9 #include <boost/variant2/variant.hpp>
10 #include <boost/core/lightweight_test_trait.hpp>
11 #include <boost/config.hpp>
12 #include <boost/config/workaround.hpp>
13 
14 #include <boost/mp11.hpp>
15 using namespace boost::mp11;
16 
17 //
18 
19 using namespace boost::variant2;
20 
21 struct D
22 {
~DD23     ~D() noexcept {}
24 };
25 
26 struct CC1
27 {
CC1CC128     CC1( CC1 const& ) {}
29 };
30 
31 struct CC2
32 {
33     CC2( CC2 const& ) = delete;
34 };
35 
36 struct MC1
37 {
MC1MC138     MC1( MC1 && ) {}
39 };
40 
41 struct MC2
42 {
43     MC2( MC2 && ) = delete;
44 };
45 
46 struct CA1
47 {
operator =CA148     CA1& operator=( CA1 const& ) { return *this; }
49 };
50 
51 struct CA2
52 {
53     CA2& operator=( CA2 const& ) = delete;
54 };
55 
56 struct MA1
57 {
operator =MA158     MA1& operator=( MA1 && ) { return *this; }
59 };
60 
61 struct MA2
62 {
63     MA2& operator=( MA2 && ) = delete;
64 };
65 
66 struct test
67 {
operator ()test68     template<class... T> void operator()( mp_list<T...> ) const noexcept
69     {
70         using U = mp_inherit<T...>;
71 
72 #if !BOOST_WORKAROUND( __GNUC__, < 5 )
73 
74         BOOST_TEST_EQ( std::is_copy_constructible<variant<U>>::value, std::is_copy_constructible<U>::value );
75         BOOST_TEST_EQ( std::is_nothrow_copy_constructible<variant<U>>::value, std::is_nothrow_copy_constructible<U>::value );
76 
77 #endif
78 
79 #if !BOOST_WORKAROUND(BOOST_MSVC, < 1910)
80 
81         BOOST_TEST_EQ( std::is_move_constructible<variant<U>>::value, std::is_move_constructible<U>::value );
82 
83 #else
84 
85         BOOST_TEST_GE( std::is_move_constructible<variant<U>>::value, std::is_move_constructible<U>::value );
86 
87 #endif
88 
89         BOOST_TEST_EQ( std::is_nothrow_move_constructible<variant<U>>::value, std::is_nothrow_move_constructible<U>::value );
90 
91         BOOST_TEST_EQ( std::is_copy_assignable<variant<U>>::value, std::is_copy_constructible<U>::value && std::is_copy_assignable<U>::value );
92         BOOST_TEST_EQ( std::is_nothrow_copy_assignable<variant<U>>::value, std::is_nothrow_copy_constructible<U>::value && std::is_copy_assignable<U>::value );
93 
94         BOOST_TEST_EQ( std::is_move_assignable<variant<U>>::value, std::is_move_constructible<U>::value && std::is_move_assignable<U>::value );
95         BOOST_TEST_EQ( std::is_nothrow_move_assignable<variant<U>>::value, std::is_nothrow_move_constructible<U>::value && std::is_move_assignable<U>::value );
96     }
97 };
98 
main()99 int main()
100 {
101     mp_for_each< mp_power_set< mp_list<D, CC1, CC2, MC1, MC2, CA1, CA2, MA1, MA2> > >( test() );
102     return boost::report_errors();
103 }
104