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