blob: 3a759781977c9880c331c2389eeeff334d1e57f7 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
Jeff Thompson3d613fd2013-10-15 15:39:04 -07002#ifndef NDNBOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED
3#define NDNBOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -07004
5// Copyright Aleksey Gurtovoy 2003-2004
6// Copyright David Abrahams 2003-2004
7//
8// Distributed under the Boost Software License, Version 1.0.
9// (See accompanying file LICENSE_1_0.txt or copy at
10// http://www.boost.org/LICENSE_1_0.txt)
11//
12// See http://www.boost.org/libs/mpl for documentation.
13
14// $Id: inserter_algorithm.hpp 55648 2009-08-18 05:16:53Z agurtovoy $
15// $Date: 2009-08-17 22:16:53 -0700 (Mon, 17 Aug 2009) $
16// $Revision: 55648 $
17
18#include <ndnboost/mpl/back_inserter.hpp>
19#include <ndnboost/mpl/front_inserter.hpp>
20#include <ndnboost/mpl/push_back.hpp>
21#include <ndnboost/mpl/push_front.hpp>
22#include <ndnboost/mpl/back_inserter.hpp>
23#include <ndnboost/mpl/front_inserter.hpp>
24#include <ndnboost/mpl/clear.hpp>
25#include <ndnboost/mpl/eval_if.hpp>
26#include <ndnboost/mpl/if.hpp>
27#include <ndnboost/mpl/aux_/na.hpp>
28#include <ndnboost/mpl/aux_/common_name_wknd.hpp>
29#include <ndnboost/mpl/aux_/na_spec.hpp>
30#include <ndnboost/mpl/aux_/preprocessor/params.hpp>
31#include <ndnboost/mpl/aux_/preprocessor/default_params.hpp>
32#include <ndnboost/mpl/aux_/config/ctps.hpp>
33
34#include <ndnboost/preprocessor/arithmetic/dec.hpp>
35
Jeff Thompson3d613fd2013-10-15 15:39:04 -070036#if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -070037
Jeff Thompson3d613fd2013-10-15 15:39:04 -070038# define NDNBOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(arity, name) \
39NDNBOOST_MPL_AUX_COMMON_NAME_WKND(name) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070040template< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070041 NDNBOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070042 > \
43struct name \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070044 : aux::name##_impl<NDNBOOST_MPL_PP_PARAMS(arity, P)> \
Jeff Thompsona28eed82013-08-22 16:21:10 -070045{ \
46}; \
47\
48template< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070049 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), typename P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070050 > \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070051struct name< NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P),na > \
Jeff Thompsona28eed82013-08-22 16:21:10 -070052 : if_< has_push_back< typename clear<P1>::type> \
53 , aux::name##_impl< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070054 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070055 , back_inserter< typename clear<P1>::type > \
56 > \
57 , aux::reverse_##name##_impl< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070058 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070059 , front_inserter< typename clear<P1>::type > \
60 > \
61 >::type \
62{ \
63}; \
64\
65template< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070066 NDNBOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070067 > \
68struct reverse_##name \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070069 : aux::reverse_##name##_impl<NDNBOOST_MPL_PP_PARAMS(arity, P)> \
Jeff Thompsona28eed82013-08-22 16:21:10 -070070{ \
71}; \
72\
73template< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070074 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), typename P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070075 > \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070076struct reverse_##name< NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P),na > \
Jeff Thompsona28eed82013-08-22 16:21:10 -070077 : if_< has_push_back<P1> \
78 , aux::reverse_##name##_impl< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070079 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070080 , back_inserter< typename clear<P1>::type > \
81 > \
82 , aux::name##_impl< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070083 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070084 , front_inserter< typename clear<P1>::type > \
85 > \
86 >::type \
87{ \
88}; \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070089NDNBOOST_MPL_AUX_NA_SPEC(arity, name) \
90NDNBOOST_MPL_AUX_NA_SPEC(arity, reverse_##name) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070091/**/
92
93#else
94
Jeff Thompson3d613fd2013-10-15 15:39:04 -070095# define NDNBOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(arity, name) \
96NDNBOOST_MPL_AUX_COMMON_NAME_WKND(name) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070097template< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070098 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), typename P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070099 > \
100struct def_##name##_impl \
101 : if_< has_push_back<P1> \
102 , aux::name##_impl< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700103 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700104 , back_inserter< typename clear<P1>::type > \
105 > \
106 , aux::reverse_##name##_impl< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700107 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700108 , front_inserter< typename clear<P1>::type > \
109 > \
110 >::type \
111{ \
112}; \
113\
114template< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700115 NDNBOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700116 > \
117struct name \
118{ \
119 typedef typename eval_if< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700120 is_na<NDNBOOST_PP_CAT(P, arity)> \
121 , def_##name##_impl<NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P)> \
122 , aux::name##_impl<NDNBOOST_MPL_PP_PARAMS(arity, P)> \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700123 >::type type; \
124}; \
125\
126template< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700127 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), typename P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700128 > \
129struct def_reverse_##name##_impl \
130 : if_< has_push_back<P1> \
131 , aux::reverse_##name##_impl< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700132 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700133 , back_inserter< typename clear<P1>::type > \
134 > \
135 , aux::name##_impl< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700136 NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700137 , front_inserter< typename clear<P1>::type > \
138 > \
139 >::type \
140{ \
141}; \
142template< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700143 NDNBOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700144 > \
145struct reverse_##name \
146{ \
147 typedef typename eval_if< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700148 is_na<NDNBOOST_PP_CAT(P, arity)> \
149 , def_reverse_##name##_impl<NDNBOOST_MPL_PP_PARAMS(NDNBOOST_PP_DEC(arity), P)> \
150 , aux::reverse_##name##_impl<NDNBOOST_MPL_PP_PARAMS(arity, P)> \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700151 >::type type; \
152}; \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700153NDNBOOST_MPL_AUX_NA_SPEC(arity, name) \
154NDNBOOST_MPL_AUX_NA_SPEC(arity, reverse_##name) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700155/**/
156
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700157#endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700158
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700159#endif // NDNBOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED