2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
10 // Test that header file is self-contained.
11 #include <boost/beast/core/detail/empty_base_optimization.hpp>
13 #include <boost/beast/unit_test/suite.hpp>
19 class empty_base_optimization_test
20 : public beast::unit_test::suite
25 : private empty_base_optimization
<T
>
27 using Base
= empty_base_optimization
<T
>;
30 explicit test1 (T
const& t
)
34 T
& member() {return Base::member();}
35 T
const& member() const {return Base::member();}
44 explicit test2 (T
const& t
)
48 T
& member() {return m_t
;}
49 T
const& member() const {return m_t
;}
54 operator bool() {return true;}
63 static_assert(sizeof(t1
) == sizeof(t2
), "don't optimize for int");
75 test1
<Empty
> t1((Empty()));
76 test2
<Empty
> t2((Empty()));
77 static_assert(sizeof(t1
) < sizeof(t2
), "do optimize for Empty");
78 if(t1
.member() != true)
80 if(t2
.member() != true)
88 BEAST_EXPECT(test_one());
89 BEAST_EXPECT(test_two());
94 BEAST_DEFINE_TESTSUITE(beast
,core
,empty_base_optimization
);