• 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 struct D
20 {
~DD21     ~D() noexcept {}
22 };
23 
24 struct CC1
25 {
CC1CC126     CC1( CC1 const& ) noexcept {}
27 };
28 
29 struct CC2
30 {
31     CC2( CC2 const& ) = delete;
32 };
33 
34 struct MC1
35 {
MC1MC136     MC1( MC1 && ) noexcept {}
37 };
38 
39 struct MC2
40 {
41     MC2( MC2 && ) = delete;
42 };
43 
44 struct CA1
45 {
operator =CA146     CA1& operator=( CA1 const& ) noexcept { return *this; }
47 };
48 
49 struct CA2
50 {
51     CA2& operator=( CA2 const& ) = delete;
52 };
53 
54 struct MA1
55 {
operator =MA156     MA1& operator=( MA1 && ) noexcept { return *this; }
57 };
58 
59 struct MA2
60 {
61     MA2& operator=( MA2 && ) = delete;
62 };
63 
64 using namespace boost::variant2;
65 namespace v2d = boost::variant2::detail;
66 
67 struct test
68 {
operator ()test69     template<class... T> void operator()( mp_list<T...> ) const noexcept
70     {
71         using U = mp_inherit<T...>;
72 
73 #if !BOOST_WORKAROUND( __GNUC__, < 5 )
74 
75         BOOST_TEST_EQ( v2d::is_trivially_copy_constructible<variant<U>>::value, v2d::is_trivially_copy_constructible<U>::value );
76         BOOST_TEST_EQ( v2d::is_trivially_copy_assignable<variant<U>>::value, std::is_trivially_destructible<U>::value && v2d::is_trivially_copy_constructible<U>::value && v2d::is_trivially_copy_assignable<U>::value );
77 
78 #endif
79 
80         BOOST_TEST_EQ( std::is_trivially_destructible<variant<U>>::value, std::is_trivially_destructible<U>::value );
81 
82 #if !BOOST_WORKAROUND(BOOST_LIBSTDCXX_VERSION, < 50000)
83 
84         BOOST_TEST_EQ( v2d::is_trivially_move_constructible<variant<U>>::value, v2d::is_trivially_move_constructible<U>::value );
85         BOOST_TEST_EQ( v2d::is_trivially_move_assignable<variant<U>>::value, std::is_trivially_destructible<U>::value && v2d::is_trivially_move_constructible<U>::value && v2d::is_trivially_move_assignable<U>::value );
86 
87 #endif
88     }
89 };
90 
main()91 int main()
92 {
93     mp_for_each< mp_power_set< mp_list<D, CC1, CC2, MC1, MC2, CA1, CA2, MA1, MA2> > >( test() );
94     return boost::report_errors();
95 }
96