| 1 | // Copyright 2023 Peter Dimov |
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // https://www.boost.org/LICENSE_1_0.txt |
| 4 | |
| 5 | #include <boost/variant2/variant.hpp> |
| 6 | #include <type_traits> |
| 7 | |
| 8 | using namespace boost::variant2; |
| 9 | |
| 10 | #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) |
| 11 | |
| 12 | struct X1 |
| 13 | { |
| 14 | }; |
| 15 | |
| 16 | STATIC_ASSERT( std::is_nothrow_move_constructible<X1>::value ); |
| 17 | STATIC_ASSERT( std::is_trivially_destructible<X1>::value ); |
| 18 | |
| 19 | struct X2 |
| 20 | { |
| 21 | ~X2() {} |
| 22 | }; |
| 23 | |
| 24 | STATIC_ASSERT( std::is_nothrow_move_constructible<X2>::value ); |
| 25 | STATIC_ASSERT( !std::is_trivially_destructible<X2>::value ); |
| 26 | |
| 27 | struct X3 |
| 28 | { |
| 29 | X3( X3&& ) {} |
| 30 | }; |
| 31 | |
| 32 | STATIC_ASSERT( !std::is_nothrow_move_constructible<X3>::value ); |
| 33 | STATIC_ASSERT( std::is_trivially_destructible<X3>::value ); |
| 34 | |
| 35 | struct X4 |
| 36 | { |
| 37 | ~X4() {} |
| 38 | X4( X4&& ) {} |
| 39 | }; |
| 40 | |
| 41 | STATIC_ASSERT( !std::is_nothrow_move_constructible<X4>::value ); |
| 42 | STATIC_ASSERT( !std::is_trivially_destructible<X4>::value ); |
| 43 | |
| 44 | // |
| 45 | |
| 46 | STATIC_ASSERT( !variant<int, float>::uses_double_storage() ); |
| 47 | STATIC_ASSERT( !variant<int, float, X1>::uses_double_storage() ); |
| 48 | STATIC_ASSERT( !variant<int, float, X2>::uses_double_storage() ); |
| 49 | STATIC_ASSERT( variant<int, float, X3>::uses_double_storage() ); |
| 50 | STATIC_ASSERT( variant<int, float, X4>::uses_double_storage() ); |
| 51 | |