#include #include "example.hpp" #if !defined(METAL_WORKAROUND) #include #include #include #include #include #include /// [make_array] template, sizeof...(Xs)> > constexpr R make_array(Xs&&... xs) { return R{{std::forward(xs)...}}; } /// [make_array] /// [tuples] using namespace std::chrono; using namespace std::literals::chrono_literals; using namespace std::literals::complex_literals; auto tup1 = std::make_tuple(42ns, 0x42, 42.f); auto tup2 = std::make_tuple(42us, 042L, 42.L); auto tup3 = std::make_tuple(42ms, 42LL, 42.i); /// [tuples] #if 0 /// [naive_array_of_tuples] auto array_of_tuples = make_array(tup1, tup2, tup3); /// [naive_array_of_tuples] #endif #include #if defined(BOOST_HANA_CONFIG_GCC) && \ BOOST_HANA_CONFIG_GCC < BOOST_HANA_CONFIG_VERSION(5, 4, 0) # define SKIP #endif #if defined(BOOST_HANA_CONFIG_CLANG) && \ BOOST_HANA_CONFIG_CLANG < BOOST_HANA_CONFIG_VERSION(3, 5, 0) # define SKIP #endif #if !defined(SKIP) #include #include #include #include #include namespace hana { /// [hana_common_tuple_t] template using hana_common_tuple_t = typename decltype( boost::hana::unpack( boost::hana::zip_with( boost::hana::template_, boost::hana::zip_with(boost::hana::decltype_, std::declval())... ), boost::hana::template_ ) )::type; /// [hana_common_tuple_t] /// [hana_make_array_of_tuples] template, sizeof...(Xs)> > constexpr R hana_make_array(Xs&&... xs) { return R{{std::forward(xs)...}}; } template, std::decay_t...>, 1 + sizeof...(Tail)> > constexpr R hana_make_array(Head&& head, Tail&&... tail) { return R{{std::forward(head), std::forward(tail)...}}; } /// [hana_make_array_of_tuples] #if !defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 5000 /// [hana_array_of_tuples] auto array_of_tuples = hana_make_array(tup1, tup2, tup3); IS_SAME(decltype(array_of_tuples), std::array>, 3>); /// [hana_array_of_tuples] #endif #if 0 /// [hana_array_of_numbers] IS_SAME(decltype(hana_make_array(42, 42L, 42LL)), std::array); /// [hana_array_of_numbers] #endif } #endif namespace { /// [common_tuple_t] template using common_tuple_t = metal::apply< std::common_type_t, metal::as_lambda...>, metal::transform, metal::as_list...> >; /// [common_tuple_t] /// [make_array_of_tuples] template, sizeof...(Xs)> > constexpr R make_array(Xs&&... xs) { return R{{std::forward(xs)...}}; } template, std::decay_t...>, 1 + sizeof...(Tail)> > constexpr R make_array(Head&& head, Tail&&... tail) { return R{{std::forward(head), std::forward(tail)...}}; } /// [make_array_of_tuples] #if !defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 5000 /// [array_of_tuples] auto array_of_tuples = make_array(tup1, tup2, tup3); IS_SAME(decltype(array_of_tuples), std::array>, 3>); /// [array_of_tuples] #endif /// [array_of_numbers] IS_SAME(decltype(make_array(42, 42L, 42LL)), std::array); /// [array_of_numbers] } #endif