| 1 | /* |
| 2 | Copyright 2018 Glen Joseph Fernandes |
| 3 | (glenjofe@gmail.com) |
| 4 | |
| 5 | Distributed under the Boost Software License, Version 1.0. |
| 6 | (http://www.boost.org/LICENSE_1_0.txt) |
| 7 | */ |
| 8 | #include <boost/config.hpp> |
| 9 | #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
| 10 | #include <boost/core/empty_value.hpp> |
| 11 | #include <boost/core/lightweight_test.hpp> |
| 12 | |
| 13 | struct T1 { }; |
| 14 | |
| 15 | struct S1 |
| 16 | : boost::empty_value<T1, 0, true> { }; |
| 17 | |
| 18 | struct T2 { |
| 19 | int value; |
| 20 | }; |
| 21 | |
| 22 | struct S2 |
| 23 | : boost::empty_value<T1, 0, true> |
| 24 | , boost::empty_value<T2, 1, true> { }; |
| 25 | |
| 26 | struct S3 |
| 27 | : boost::empty_value<T1, 0, false> |
| 28 | , boost::empty_value<T2, 1, true> { }; |
| 29 | |
| 30 | struct T3 { }; |
| 31 | |
| 32 | struct S4 |
| 33 | : boost::empty_value<T1, 0, true> |
| 34 | , boost::empty_value<T3, 1, true> { }; |
| 35 | |
| 36 | struct S5 |
| 37 | : boost::empty_value<T1, 0, false> |
| 38 | , boost::empty_value<T3, 1, false> { }; |
| 39 | |
| 40 | struct S6 |
| 41 | : boost::empty_value<T1, 0, true> |
| 42 | , boost::empty_value<T2, 1, true> |
| 43 | , boost::empty_value<T3, 2, true> { }; |
| 44 | |
| 45 | int main() |
| 46 | { |
| 47 | BOOST_TEST(sizeof(S1) == sizeof(T1)); |
| 48 | BOOST_TEST(sizeof(S2) == sizeof(T2)); |
| 49 | BOOST_TEST(sizeof(S3) > sizeof(T2)); |
| 50 | BOOST_TEST(sizeof(S4) == sizeof(T1)); |
| 51 | BOOST_TEST(sizeof(S5) > sizeof(T1)); |
| 52 | BOOST_TEST(sizeof(S6) == sizeof(T2)); |
| 53 | return boost::report_errors(); |
| 54 | } |
| 55 | #else |
| 56 | int main() |
| 57 | { |
| 58 | return 0; |
| 59 | } |
| 60 | #endif |
| 61 | |