• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright Louis Dionne 2013-2017
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/assert.hpp>
6 #include <boost/hana/config.hpp>
7 #include <boost/hana/core/to.hpp>
8 #include <boost/hana/equal.hpp>
9 #include <boost/hana/tuple.hpp>
10 namespace hana = boost::hana;
11 
12 
13 template <typename X, typename Y, typename Z>
14 struct Triple {
15     X first;
16     Y second;
17     Z third;
18 };
19 
__anon56c12a2f0102(auto x, auto y, auto z) 20 BOOST_HANA_CONSTEXPR_LAMBDA auto triple = [](auto x, auto y, auto z) {
21     return Triple<decltype(x), decltype(y), decltype(z)>{x, y, z};
22 };
23 
24 namespace boost { namespace hana {
25     template <typename X, typename Y, typename Z>
26     struct to_impl<tuple_tag, Triple<X, Y, Z>> {
applyboost::hana::to_impl27         static constexpr auto apply(Triple<X, Y, Z> xs) {
28             return make_tuple(xs.first, xs.second, xs.third);
29         }
30     };
31 }}
32 
main()33 int main() {
34     BOOST_HANA_CONSTEXPR_CHECK(
35         hana::to<hana::tuple_tag>(triple(1, '2', 3.3)) == hana::make_tuple(1, '2', 3.3)
36     );
37 }
38