29 #include <ableton/build_system/Warnings.hpp>
31 #include <boost/mpl/sequence_tag.hpp>
32 #include <boost/mpl/pop_front_fwd.hpp>
33 #include <boost/mpl/push_front_fwd.hpp>
34 #include <boost/mpl/push_back_fwd.hpp>
35 #include <boost/mpl/front_fwd.hpp>
36 #include <boost/mpl/empty_fwd.hpp>
37 #include <boost/mpl/size_fwd.hpp>
38 #include <boost/mpl/at_fwd.hpp>
39 #include <boost/mpl/back_fwd.hpp>
40 #include <boost/mpl/clear_fwd.hpp>
41 #include <boost/mpl/pop_back_fwd.hpp>
42 #include <boost/mpl/iterator_tags.hpp>
43 #include <boost/mpl/next_prior.hpp>
44 #include <boost/mpl/deref.hpp>
45 #include <boost/mpl/begin_end_fwd.hpp>
58 template <
class ... Args>
61 template <
class ... Args>
64 typedef atria::meta::std_tuple_tag tag;
65 typedef boost::mpl::forward_iterator_tag category;
74 template <
class ... Args>
75 struct sequence_tag<
std::tuple<Args...>>
77 typedef atria::meta::std_tuple_tag type;
81 struct front_impl<
atria::meta::std_tuple_tag>
83 template <
typename Tuple>
85 : std::tuple_element<0, Tuple>
91 struct empty_impl<
atria::meta::std_tuple_tag>
93 template <
typename Tuple>
struct apply
94 : std::integral_constant<bool, std::tuple_size<Tuple>::value == 0>
100 struct pop_front_impl<
atria::meta::std_tuple_tag>
102 template <
typename Tuple>
struct apply;
104 template <
class First,
class ... Types>
struct apply<
std::tuple<First, Types...>>
106 typedef std::tuple<Types...> type;
111 struct push_front_impl<
atria::meta::std_tuple_tag>
113 template <
typename Tuple,
typename T>
struct apply;
115 template <
typename T,
typename ... Args>
116 struct apply<
std::tuple<Args...>, T>
118 typedef std::tuple<T, Args...> type;
123 struct push_back_impl<
atria::meta::std_tuple_tag>
125 template <
typename Tuple,
typename T>
struct apply;
127 template <
typename T,
typename ... Args >
128 struct apply<
std::tuple<Args...>, T>
130 typedef std::tuple<Args..., T> type;
136 struct size_impl<
atria::meta::std_tuple_tag>
138 template <
typename Tuple>
struct apply
139 : std::tuple_size<Tuple>
145 struct at_impl<
atria::meta::std_tuple_tag>
147 template <
typename Tuple,
typename N>
struct apply
148 : std::tuple_element<N::value, Tuple>
154 struct back_impl<
atria::meta::std_tuple_tag>
156 template <
typename Tuple>
struct apply
157 : std::tuple_element<std::tuple_size<Tuple>::value - 1, Tuple>
163 struct clear_impl<
atria::meta::std_tuple_tag>
165 template <
typename Tuple>
struct apply
167 typedef std::tuple<> type;
172 struct pop_back_impl<
atria::meta::std_tuple_tag>
174 template <
int ...>
struct tuple_seq {};
175 template <
int N,
int ...S>
struct tuple_gens : tuple_gens<N-1, N-1, S...> {};
176 template <
int ...S>
struct tuple_gens<0, S...>{
typedef tuple_seq<S...> type; };
178 template <
class Tuple,
class Index>
struct apply_impl;
179 template <
class Tuple,
int ... S>
struct apply_impl<Tuple, tuple_seq<S...>>
181 typedef std::tuple<typename std::tuple_element<S, Tuple>::type...> type;
184 template <
typename Tuple>
struct apply : apply_impl<Tuple, typename tuple_gens<std::tuple_size<Tuple>::value - 1>::type> { };
188 struct begin_impl<
atria::meta::std_tuple_tag>
190 template <
class Tuple>
struct apply
197 struct end_impl<
atria::meta::std_tuple_tag>
199 template <
typename>
struct apply
205 template <
typename First,
class ... Args>
206 struct deref<
atria::meta::std_tuple_iterator<std::tuple<First, Args...>>>
211 template <
typename First,
class ... Args>
212 struct next<
atria::meta::std_tuple_iterator<std::tuple<First, Args...>>>
C++ amazing templates and reusable implementations awesomeness.