2 // Copyright (c) 2013-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)
8 // Test that header file is self-contained.
9 #include <beast/core/detail/empty_base_optimization.hpp>
11 #include <beast/unit_test/suite.hpp>
16 class empty_base_optimization_test
17 : public beast::unit_test::suite
22 : private empty_base_optimization
<T
>
24 using Base
= empty_base_optimization
<T
>;
27 explicit test1 (T
const& t
)
31 T
& member() {return Base::member();}
32 T
const& member() const {return Base::member();}
41 explicit test2 (T
const& t
)
45 T
& member() {return m_t
;}
46 T
const& member() const {return m_t
;}
51 operator bool() {return true;}
60 static_assert(sizeof(t1
) == sizeof(t2
), "don't optimize for int");
72 test1
<Empty
> t1((Empty()));
73 test2
<Empty
> t2((Empty()));
74 static_assert(sizeof(t1
) < sizeof(t2
), "do optimize for Empty");
75 if(t1
.member() != true)
77 if(t2
.member() != true)
85 BEAST_EXPECT(test_one());
86 BEAST_EXPECT(test_two());
91 BEAST_DEFINE_TESTSUITE(empty_base_optimization
,core
,beast
);