blob: cfbe84e3506ffc814f528c2bfc385cc7dad74c66 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
2#ifndef BOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED
3#define BOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED
4
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
36#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
37
38# define BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(arity, name) \
39BOOST_MPL_AUX_COMMON_NAME_WKND(name) \
40template< \
41 BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
42 > \
43struct name \
44 : aux::name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \
45{ \
46}; \
47\
48template< \
49 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \
50 > \
51struct name< BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P),na > \
52 : if_< has_push_back< typename clear<P1>::type> \
53 , aux::name##_impl< \
54 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
55 , back_inserter< typename clear<P1>::type > \
56 > \
57 , aux::reverse_##name##_impl< \
58 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
59 , front_inserter< typename clear<P1>::type > \
60 > \
61 >::type \
62{ \
63}; \
64\
65template< \
66 BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
67 > \
68struct reverse_##name \
69 : aux::reverse_##name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \
70{ \
71}; \
72\
73template< \
74 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \
75 > \
76struct reverse_##name< BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P),na > \
77 : if_< has_push_back<P1> \
78 , aux::reverse_##name##_impl< \
79 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
80 , back_inserter< typename clear<P1>::type > \
81 > \
82 , aux::name##_impl< \
83 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
84 , front_inserter< typename clear<P1>::type > \
85 > \
86 >::type \
87{ \
88}; \
89BOOST_MPL_AUX_NA_SPEC(arity, name) \
90BOOST_MPL_AUX_NA_SPEC(arity, reverse_##name) \
91/**/
92
93#else
94
95# define BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(arity, name) \
96BOOST_MPL_AUX_COMMON_NAME_WKND(name) \
97template< \
98 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \
99 > \
100struct def_##name##_impl \
101 : if_< has_push_back<P1> \
102 , aux::name##_impl< \
103 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
104 , back_inserter< typename clear<P1>::type > \
105 > \
106 , aux::reverse_##name##_impl< \
107 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
108 , front_inserter< typename clear<P1>::type > \
109 > \
110 >::type \
111{ \
112}; \
113\
114template< \
115 BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
116 > \
117struct name \
118{ \
119 typedef typename eval_if< \
120 is_na<BOOST_PP_CAT(P, arity)> \
121 , def_##name##_impl<BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P)> \
122 , aux::name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \
123 >::type type; \
124}; \
125\
126template< \
127 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \
128 > \
129struct def_reverse_##name##_impl \
130 : if_< has_push_back<P1> \
131 , aux::reverse_##name##_impl< \
132 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
133 , back_inserter< typename clear<P1>::type > \
134 > \
135 , aux::name##_impl< \
136 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
137 , front_inserter< typename clear<P1>::type > \
138 > \
139 >::type \
140{ \
141}; \
142template< \
143 BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
144 > \
145struct reverse_##name \
146{ \
147 typedef typename eval_if< \
148 is_na<BOOST_PP_CAT(P, arity)> \
149 , def_reverse_##name##_impl<BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P)> \
150 , aux::reverse_##name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \
151 >::type type; \
152}; \
153BOOST_MPL_AUX_NA_SPEC(arity, name) \
154BOOST_MPL_AUX_NA_SPEC(arity, reverse_##name) \
155/**/
156
157#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
158
159#endif // BOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED