2
0
mirror of https://github.com/boostorg/hana.git synced 2026-01-24 05:52:14 +00:00

[Tests] Actually workaround the missing EBO on Windows

This commit is contained in:
Louis Dionne
2015-11-11 18:00:57 -05:00
parent 76a0ac16a4
commit db487b2b42

View File

@@ -7,12 +7,10 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/hana/tuple.hpp>
namespace hana = boost::hana;
//
// We disable this test when the compiler does not support the empty base
// class optimization (EBO). Compilers normally support it, but Clang for
// Windows emulates the broken behaviour of MSVC, and does not support the
// EBO for more than one base class. See https://goo.gl/5FE3R6 for more info.
// This test makes sure that `hana::tuple` has a simple enough representation.
// In particular, we make sure that the empty base-class optimization (EBO)
// is able to fire, when supported.
//
template <typename T>
@@ -23,22 +21,11 @@ struct inherit : T... { };
struct A { };
struct B { };
static constexpr bool EBO_is_supported = sizeof(inherit<A, holder<int>>) == sizeof(int);
template <bool = EBO_is_supported, typename EmptyA = A, typename EmptyB = B>
struct test {
static_assert((sizeof(hana::tuple<int, EmptyA>) == sizeof(int)), "");
static_assert((sizeof(hana::tuple<EmptyA, int>) == sizeof(int)), "");
static_assert((sizeof(hana::tuple<EmptyA, int, EmptyB>) == sizeof(int)), "");
static_assert((sizeof(hana::tuple<EmptyA, EmptyB, int>) == sizeof(int)), "");
static_assert((sizeof(hana::tuple<int, EmptyA, EmptyB>) == sizeof(int)), "");
};
template <>
struct test<false> {
// Nothing to test
};
template struct test<>;
static_assert((sizeof(hana::tuple<int, A>) == sizeof(inherit<holder<int>, A>)), "");
static_assert((sizeof(hana::tuple<A, int>) == sizeof(inherit<A, holder<int>>)), "");
static_assert((sizeof(hana::tuple<A, int, B>) == sizeof(inherit<A, holder<int>, B>)), "");
static_assert((sizeof(hana::tuple<A, B, int>) == sizeof(inherit<A, B, holder<int>>)), "");
static_assert((sizeof(hana::tuple<int, A, B>) == sizeof(inherit<holder<int>, A, B>)), "");
int main() { }