Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 1 | |
| 2 | // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION |
| 3 | |
| 4 | // Copyright Aleksey Gurtovoy 2002-2004 |
| 5 | // |
| 6 | // Distributed under the Boost Software License, Version 1.0. |
| 7 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 8 | // http://www.boost.org/LICENSE_1_0.txt) |
| 9 | |
| 10 | // $Source$ |
| 11 | // $Date: 2011-10-09 15:28:33 -0700 (Sun, 09 Oct 2011) $ |
| 12 | // $Revision: 74865 $ |
| 13 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 14 | #include <ndnboost/type_traits/detail/template_arity_spec.hpp> |
| 15 | #include <ndnboost/type_traits/integral_constant.hpp> |
| 16 | #include <ndnboost/mpl/bool.hpp> |
| 17 | #include <ndnboost/mpl/aux_/lambda_support.hpp> |
| 18 | #include <ndnboost/config.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 19 | |
| 20 | // |
| 21 | // Unfortunately some libraries have started using this header without |
| 22 | // cleaning up afterwards: so we'd better undef the macros just in case |
| 23 | // they've been defined already.... |
| 24 | // |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 25 | #ifdef NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL |
| 26 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL |
| 27 | #undef NDNBOOST_TT_AUX_BOOL_C_BASE |
| 28 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1 |
| 29 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_DEF2 |
| 30 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1 |
| 31 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC2 |
| 32 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1 |
| 33 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2 |
| 34 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1 |
| 35 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2 |
| 36 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1 |
| 37 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2 |
| 38 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1 |
| 39 | #undef NDNBOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 40 | #endif |
| 41 | |
| 42 | #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x570) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 43 | # define NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 44 | typedef ::ndnboost::integral_constant<bool,C> type; \ |
| 45 | enum { value = type::value }; \ |
| 46 | /**/ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 47 | # define NDNBOOST_TT_AUX_BOOL_C_BASE(C) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 48 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 49 | #elif defined(NDNBOOST_MSVC) && NDNBOOST_MSVC < 1300 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 50 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 51 | # define NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 52 | typedef ::ndnboost::integral_constant<bool,C> base_; \ |
| 53 | using base_::value; \ |
| 54 | /**/ |
| 55 | |
| 56 | #endif |
| 57 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 58 | #ifndef NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL |
| 59 | # define NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) /**/ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 60 | #endif |
| 61 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 62 | #ifndef NDNBOOST_TT_AUX_BOOL_C_BASE |
| 63 | # define NDNBOOST_TT_AUX_BOOL_C_BASE(C) : public ::ndnboost::integral_constant<bool,C> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 64 | #endif |
| 65 | |
| 66 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 67 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(trait,T,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 68 | template< typename T > struct trait \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 69 | NDNBOOST_TT_AUX_BOOL_C_BASE(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 70 | { \ |
| 71 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 72 | NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
| 73 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(1,trait,(T)) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 74 | }; \ |
| 75 | \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 76 | NDNBOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,trait) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 77 | /**/ |
| 78 | |
| 79 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 80 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_DEF2(trait,T1,T2,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 81 | template< typename T1, typename T2 > struct trait \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 82 | NDNBOOST_TT_AUX_BOOL_C_BASE(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 83 | { \ |
| 84 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 85 | NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
| 86 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(2,trait,(T1,T2)) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 87 | }; \ |
| 88 | \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 89 | NDNBOOST_TT_AUX_TEMPLATE_ARITY_SPEC(2,trait) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 90 | /**/ |
| 91 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 92 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_DEF3(trait,T1,T2,T3,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 93 | template< typename T1, typename T2, typename T3 > struct trait \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 94 | NDNBOOST_TT_AUX_BOOL_C_BASE(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 95 | { \ |
| 96 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 97 | NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
| 98 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(3,trait,(T1,T2,T3)) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 99 | }; \ |
| 100 | \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 101 | NDNBOOST_TT_AUX_TEMPLATE_ARITY_SPEC(3,trait) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 102 | /**/ |
| 103 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 104 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 105 | template<> struct trait< sp > \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 106 | NDNBOOST_TT_AUX_BOOL_C_BASE(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 107 | { \ |
| 108 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 109 | NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
| 110 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,trait,(sp)) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 111 | }; \ |
| 112 | /**/ |
| 113 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 114 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC2(trait,sp1,sp2,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 115 | template<> struct trait< sp1,sp2 > \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 116 | NDNBOOST_TT_AUX_BOOL_C_BASE(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 117 | { \ |
| 118 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 119 | NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
| 120 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,trait,(sp1,sp2)) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 121 | }; \ |
| 122 | /**/ |
| 123 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 124 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(trait,sp,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 125 | template<> struct trait##_impl< sp > \ |
| 126 | { \ |
| 127 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 128 | NDNBOOST_STATIC_CONSTANT(bool, value = (C)); \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 129 | }; \ |
| 130 | /**/ |
| 131 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 132 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,sp1,sp2,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 133 | template<> struct trait##_impl< sp1,sp2 > \ |
| 134 | { \ |
| 135 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 136 | NDNBOOST_STATIC_CONSTANT(bool, value = (C)); \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 137 | }; \ |
| 138 | /**/ |
| 139 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 140 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(param,trait,sp,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 141 | template< param > struct trait< sp > \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 142 | NDNBOOST_TT_AUX_BOOL_C_BASE(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 143 | { \ |
| 144 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 145 | NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 146 | }; \ |
| 147 | /**/ |
| 148 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 149 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(param1,param2,trait,sp,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 150 | template< param1, param2 > struct trait< sp > \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 151 | NDNBOOST_TT_AUX_BOOL_C_BASE(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 152 | { \ |
| 153 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 154 | NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 155 | }; \ |
| 156 | /**/ |
| 157 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 158 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(param,trait,sp1,sp2,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 159 | template< param > struct trait< sp1,sp2 > \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 160 | NDNBOOST_TT_AUX_BOOL_C_BASE(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 161 | { \ |
| 162 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 163 | NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
| 164 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,trait,(sp1,sp2)) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 165 | }; \ |
| 166 | /**/ |
| 167 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 168 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(param1,param2,trait,sp1,sp2,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 169 | template< param1, param2 > struct trait< sp1,sp2 > \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 170 | NDNBOOST_TT_AUX_BOOL_C_BASE(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 171 | { \ |
| 172 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 173 | NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 174 | }; \ |
| 175 | /**/ |
| 176 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 177 | #define NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(param,trait,sp1,sp2,C) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 178 | template< param > struct trait##_impl< sp1,sp2 > \ |
| 179 | { \ |
| 180 | public:\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 181 | NDNBOOST_STATIC_CONSTANT(bool, value = (C)); \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 182 | }; \ |
| 183 | /**/ |
| 184 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 185 | #ifndef NDNBOOST_NO_CV_SPECIALIZATIONS |
| 186 | # define NDNBOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(trait,sp,value) \ |
| 187 | NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,value) \ |
| 188 | NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp const,value) \ |
| 189 | NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp volatile,value) \ |
| 190 | NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp const volatile,value) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 191 | /**/ |
| 192 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 193 | # define NDNBOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(trait,sp,value) \ |
| 194 | NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,value) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 195 | /**/ |
| 196 | #endif |