diff options
Diffstat (limited to 'src/boost/libs/hana/test/experimental/types/unpack.cpp')
-rw-r--r-- | src/boost/libs/hana/test/experimental/types/unpack.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/experimental/types/unpack.cpp b/src/boost/libs/hana/test/experimental/types/unpack.cpp new file mode 100644 index 000000000..96116b403 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/types/unpack.cpp @@ -0,0 +1,83 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/experimental/types.hpp> +#include <boost/hana/type.hpp> +#include <boost/hana/unpack.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; + + +template <typename ...> +struct mf { struct type; }; + +template <int> struct x; + +int main() { + // with a Metafunction + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<>{}, hana::metafunction<mf>), + hana::type_c<mf<>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>>{}, hana::metafunction<mf>), + hana::type_c<mf<x<0>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>>{}, hana::metafunction<mf>), + hana::type_c<mf<x<0>, x<1>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>>{}, hana::metafunction<mf>), + hana::type_c<mf<x<0>, x<1>, x<2>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, hana::metafunction<mf>), + hana::type_c<mf<x<0>, x<1>, x<2>, x<3>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>, x<3>, x<4>>{}, hana::metafunction<mf>), + hana::type_c<mf<x<0>, x<1>, x<2>, x<3>, x<4>>::type> + )); + } + + // with a non-Metafunction + { + auto f = hana::test::_injection<0>{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<>{}, f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>>{}, f), + f(hana::type_c<x<0>>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>>{}, f), + f(hana::type_c<x<0>>, hana::type_c<x<1>>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>>{}, f), + f(hana::type_c<x<0>>, hana::type_c<x<1>>, hana::type_c<x<2>>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, f), + f(hana::type_c<x<0>>, hana::type_c<x<1>>, hana::type_c<x<2>>, hana::type_c<x<3>>) + )); + } +} |