/* @copyright Louis Dionne 2014 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 #include #include #include #include #include //! [includes] #include using namespace boost::hana; //! [includes] int main() { //! [xs] auto xs = list(1, '2', std::string{"345"}); //! [xs] //! [value_operations] assert(last(xs) == "345"); assert(tail(xs) == list('2', std::string{"345"})); BOOST_HANA_CONSTANT_ASSERT(!is_empty(xs)); for_each(xs, [](auto x) { std::cout << x; }); //! [value_operations] //! [std_tuple_parallel] auto ys = std::make_tuple(1, '2', std::string{"345"}); static_assert(std::tuple_size::value != 0, ""); //! [std_tuple_parallel] //! [useless] using wow_that_is_so_useless = decltype(xs); //! [useless] //! [ts] auto ts = list(type, type, type); //! [ts] //! [type_operations] BOOST_HANA_CONSTANT_ASSERT(last(ts) == type); BOOST_HANA_CONSTANT_ASSERT(tail(ts) == list(type, type)); //! [type_operations] //! [type_out] static_assert(std::is_same< decltype(type)::type, char const >::value, ""); //! [type_out] //! [type_foreach] for_each(ts, [](auto t) { using T = typename decltype(t)::type; std::cout << typeid(T).name(); }); //! [type_foreach] //! [type_transformation_def] auto add_pointer = [](auto t) { using T = typename decltype(t)::type; return type::type>; }; //! [type_transformation_def] //! [type_transformation_check] static_assert(std::is_same< decltype(add_pointer(type))::type, char const* >::value, ""); //! [type_transformation_check] //! [metafunction] static_assert(std::is_same< decltype(metafunction(type))::type, char const* >::value, ""); //! [metafunction] }