MPL11
 All Classes Namespaces Files Typedefs Macros Groups Pages
std_tuple.hpp
Go to the documentation of this file.
1 
12 #ifndef BOOST_MPL11_EXT_STD_TUPLE_HPP
13 #define BOOST_MPL11_EXT_STD_TUPLE_HPP
14 
15 #include <boost/mpl11/bool.hpp>
16 #include <boost/mpl11/core.hpp>
19 #include <boost/mpl11/fwd/list.hpp>
20 #include <boost/mpl11/iterable.hpp>
21 
22 #include <tuple>
23 
24 
25 namespace boost { namespace mpl11 {
26  struct StdTuple;
27 
28  template <typename ...xs>
29  struct datatype<std::tuple<xs...>> {
30  using type = StdTuple;
31  };
32 
33  template <>
34  struct cast</* from */ StdTuple, /* to */ List> {
35  using type = cast;
36 
37  template <typename>
38  struct apply;
39 
40  template <typename ...xs>
41  struct apply<std::tuple<xs...>> {
42  using type = list<box<xs>...>;
43  };
44  };
45 
46  template <>
47  struct cast</* from */ List, /* to */ StdTuple> {
48  using type = cast;
49 
50  template <typename>
51  struct apply;
52 
53  template <typename ...xs>
54  struct apply<list<xs...>> {
55  using type = std::tuple<typename xs::type...>;
56  };
57 
58  template <typename x, typename xs>
59  struct apply<cons<x, xs>>
60  : apply<typename unpack<into<list>, cons<x, xs>>::type>
61  { };
62  };
63 
64  template <>
65  struct Iterable<StdTuple> : instantiate<Iterable>::with<StdTuple> {
66  template <typename>
67  struct head_impl;
68 
69  template <typename x, typename ...xs>
70  struct head_impl<std::tuple<x, xs...>> {
71  using type = x;
72  };
73 
74 
75  template <typename>
76  struct tail_impl;
77 
78  template <typename x, typename ...xs>
79  struct tail_impl<std::tuple<x, xs...>> {
80  using type = std::tuple<xs...>;
81  };
82 
83 
84  template <typename>
85  struct is_empty_impl;
86 
87  template <typename ...xs>
88  struct is_empty_impl<std::tuple<xs...>>
89  : bool_<sizeof...(xs) == 0>
90  { };
91  };
92 }} // end namespace boost::mpl11
93 
94 #endif // !BOOST_MPL11_EXT_STD_TUPLE_HPP
Defines the Iterable typeclass.
Defines the Core module.
Invokes a metafunction class with the given arguments.
Definition: functional.hpp:39
Forward declares the boost::mpl11::List datatype.
Forwards to boost/mpl11/integer.hpp.
Defines the Functional module.
Forward declares the Foldable typeclass.