27 #ifndef MLN_ACCU_TUPLE_HH
28 # define MLN_ACCU_TUPLE_HH
37 # include <mln/core/concept/meta_accumulator.hh>
39 # include <mln/accu/internal/base.hh>
40 # include <mln/metal/is_a.hh>
41 # include <mln/metal/unqualif.hh>
43 # include <boost/tuple/tuple.hpp>
44 # include <boost/preprocessor/iteration/local.hpp>
45 # include <boost/preprocessor/repetition/repeat.hpp>
46 # include <boost/preprocessor/repetition/enum_params.hpp>
47 # include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
49 # define RESULT_ACCU(z, n, data) BOOST_PP_COMMA_IF(n) typename internal::tuplehelper_<T ## n>::result
50 # define ARG(z, n, data) BOOST_PP_COMMA_IF(n) const T ## n& p ## n = T ## n()
51 # define BOOST_PP_LOCAL_MACRO(n) typedef mln_accu_with(T ## n, A) AT ## n;
52 # define BOOST_PP_LOCAL_LIMITS (0, 9)
63 template <
typename T>
struct tuplehelper_;
64 template <
unsigned n,
typename T>
struct tuplehelper;
73 template <
typename A,
unsigned n, BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(10,
typename T, boost::tuples::null_type)>
75 :
public mln::accu::internal::base< boost::tuple< BOOST_PP_REPEAT(10, RESULT_ACCU, Le Ricard ya que ca de vrai !) >, tuple<A, n, BOOST_PP_ENUM_PARAMS(10, T)> >
79 typedef boost::tuple< BOOST_PP_REPEAT(10, RESULT_ACCU, Le Ricard ya que ca de vrai !)>
res;
80 typedef boost::tuple< BOOST_PP_ENUM_PARAMS(10, T)>
intern;
90 void take(
const tuple<A, n, BOOST_PP_ENUM_PARAMS(10,
T)>& other);
110 template <
unsigned n, BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(10,
typename T, boost::tuples::null_type)>
113 template <
typename A>
116 # include BOOST_PP_LOCAL_ITERATE()
125 # ifndef MLN_INCLUDE_ONLY
130 template <
typename T>
133 typedef typename T::result result;
137 struct tuplehelper_<boost::tuples::null_type>
139 typedef boost::tuples::null_type result;
142 template <
unsigned n,
typename T>
145 static void init(
typename T::intern& a)
148 tuplehelper<n - 1, T>::init(a);
151 static void take_as_init_(
typename T::intern& a,
const typename T::argument& argument)
154 tuplehelper<n - 1, T>::take_as_init_(a, argument);
157 static void take(
typename T::intern& a,
const typename T::argument& argument)
163 static void take(
typename T::intern& a,
const typename T::intern& other)
169 static void to_result(
const typename T::intern& a,
typename T::result& res)
171 boost::get<n - 1>(res) = boost::get<n - 1>(a).to_result();
172 tuplehelper<n - 1, T>::to_result(a, res);
176 template <
typename T>
177 struct tuplehelper<0,
T>
179 static void init(
typename T::intern&) {}
180 static void take_as_init_(
typename T::intern&,
const typename T::argument&) {}
181 static void take(
typename T::intern&,
const typename T::argument) {}
182 static void take(
typename T::intern&,
const typename T::intern&) {}
183 static void to_result(
const typename T::intern&,
typename T::result&) {}
187 template <
typename A,
unsigned n, BOOST_PP_ENUM_PARAMS(10,
typename T)>
189 tuple<A,n,BOOST_PP_ENUM_PARAMS(10,T) >::tuple()
194 template <
typename A,
unsigned n, BOOST_PP_ENUM_PARAMS(10,
typename T)>
197 tuple<A,n,BOOST_PP_ENUM_PARAMS(10,T) >::init()
199 internal::tuplehelper<n, self>::init(this->a_);
202 template <
typename A,
unsigned n, BOOST_PP_ENUM_PARAMS(10,
typename T)>
205 tuple<A,n,BOOST_PP_ENUM_PARAMS(10,T) >::take_as_init_(
const argument& t)
207 internal::tuplehelper<n, self>::take_as_init_(this->a_, t);
210 template <
typename A,
unsigned n, BOOST_PP_ENUM_PARAMS(10,
typename T)>
213 tuple<A,n,BOOST_PP_ENUM_PARAMS(10,T) >::take(
const argument& t)
218 template <
typename A,
unsigned n, BOOST_PP_ENUM_PARAMS(10,
typename T)>
221 tuple<A,n,BOOST_PP_ENUM_PARAMS(10,T) >::take(
const tuple<A,n,BOOST_PP_ENUM_PARAMS(10,T) >&
other)
226 template <
typename A,
unsigned n, BOOST_PP_ENUM_PARAMS(10,
typename T)>
228 typename tuple<A,n,BOOST_PP_ENUM_PARAMS(10,T) >::res
229 tuple<A,n,BOOST_PP_ENUM_PARAMS(10,T) >::to_result()
const
232 internal::tuplehelper<n, self>::to_result(this->a_, tmp);
236 template <
typename A,
unsigned n, BOOST_PP_ENUM_PARAMS(10,
typename T)>
239 tuple<A,n,BOOST_PP_ENUM_PARAMS(10,T) >::is_valid()
const
244 # endif // ! MLN_INCLUDE_ONLY
251 #endif // ! MLN_ACCU_TUPLE_HH