1/*
2Copyright 2018 Glen Joseph Fernandes
3(glenjofe@gmail.com)
4
5Distributed 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
13struct T1 { };
14
15struct S1
16 : boost::empty_value<T1, 0, true> { };
17
18struct T2 {
19 int value;
20};
21
22struct S2
23 : boost::empty_value<T1, 0, true>
24 , boost::empty_value<T2, 1, true> { };
25
26struct S3
27 : boost::empty_value<T1, 0, false>
28 , boost::empty_value<T2, 1, true> { };
29
30struct T3 { };
31
32struct S4
33 : boost::empty_value<T1, 0, true>
34 , boost::empty_value<T3, 1, true> { };
35
36struct S5
37 : boost::empty_value<T1, 0, false>
38 , boost::empty_value<T3, 1, false> { };
39
40struct S6
41 : boost::empty_value<T1, 0, true>
42 , boost::empty_value<T2, 1, true>
43 , boost::empty_value<T3, 2, true> { };
44
45int 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
56int main()
57{
58 return 0;
59}
60#endif
61

source code of boost/libs/core/test/empty_value_size_test.cpp