| 1 | // Copyright Louis Dionne 2013-2022 |
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) |
| 4 | |
| 5 | #include <boost/hana/pair.hpp> |
| 6 | |
| 7 | #include <type_traits> |
| 8 | namespace hana = boost::hana; |
| 9 | |
| 10 | |
| 11 | struct empty1 { }; |
| 12 | struct empty2 { }; |
| 13 | struct empty3 { }; |
| 14 | struct empty4 { }; |
| 15 | |
| 16 | // Make sure the storage of a pair is compressed |
| 17 | static_assert(sizeof(hana::pair<empty1, int>) == sizeof(int), "" ); |
| 18 | static_assert(sizeof(hana::pair<int, empty1>) == sizeof(int), "" ); |
| 19 | |
| 20 | // Also make sure that a pair with only empty members is empty too. This is |
| 21 | // important to ensure, for example, that a tuple of pairs of empty objects |
| 22 | // will get the EBO. |
| 23 | static_assert(std::is_empty<hana::pair<empty1, empty2>>{}, "" ); |
| 24 | |
| 25 | // Make sure that a pair of empty pairs is still empty. |
| 26 | static_assert(std::is_empty< |
| 27 | hana::pair<hana::pair<empty1, empty2>, empty3> |
| 28 | >{}, "" ); |
| 29 | |
| 30 | static_assert(std::is_empty< |
| 31 | hana::pair<hana::pair<empty1, empty2>, hana::pair<empty3, empty4>> |
| 32 | >{}, "" ); |
| 33 | |
| 34 | int main() { } |
| 35 | |