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/core/empty_value.hpp>
9#include <boost/core/lightweight_test.hpp>
10
11#if !defined(BOOST_NO_CXX11_FINAL)
12class type final {
13public:
14 explicit type(int count)
15 : value_(count) { }
16 int value() const {
17 return value_ + 1;
18 }
19 int value() {
20 return value_ + 2;
21 }
22private:
23 int value_;
24};
25
26struct empty final {
27 int value() const {
28 return 1;
29 }
30 int value() {
31 return 2;
32 }
33};
34
35void test_type()
36{
37 const boost::empty_value<type> v1(boost::empty_init_t(), 3);
38 BOOST_TEST(v1.get().value() == 4);
39 boost::empty_value<type> v2(boost::empty_init_t(), 3);
40 BOOST_TEST(v2.get().value() == 5);
41}
42
43void test_empty()
44{
45 const boost::empty_value<empty> v1 = boost::empty_init_t();
46 BOOST_TEST(v1.get().value() == 1);
47 boost::empty_value<empty> v2;
48 BOOST_TEST(v2.get().value() == 2);
49}
50
51int main()
52{
53 test_type();
54 test_empty();
55 return boost::report_errors();
56}
57#else
58int main()
59{
60 return 0;
61}
62#endif
63

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