Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 1 | // Boost Lambda Library - operators.hpp -------------------------------------- |
| 2 | |
| 3 | // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) |
| 4 | // |
| 5 | // Distributed under the Boost Software License, Version 1.0. (See |
| 6 | // accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt) |
| 8 | // |
| 9 | // For more information, see www.boost.org |
| 10 | |
| 11 | // --------------------------------------------------------------- |
| 12 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 13 | #ifndef NDNBOOST_LAMBDA_OPERATORS_HPP |
| 14 | #define NDNBOOST_LAMBDA_OPERATORS_HPP |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 15 | |
| 16 | #include "ndnboost/lambda/detail/is_instance_of.hpp" |
| 17 | |
| 18 | namespace ndnboost { |
| 19 | namespace lambda { |
| 20 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 21 | #if defined NDNBOOST_LAMBDA_BE1 |
| 22 | #error "Multiple defines of NDNBOOST_LAMBDA_BE1" |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 23 | #endif |
| 24 | |
| 25 | // For all BOOSTA_LAMBDA_BE* macros: |
| 26 | |
| 27 | // CONSTA must be either 'A' or 'const A' |
| 28 | // CONSTB must be either 'B' or 'const B' |
| 29 | |
| 30 | // It is stupid to have the names A and B as macro arguments, but it avoids |
| 31 | // the need to pass in emtpy macro arguments, which gives warnings on some |
| 32 | // compilers |
| 33 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 34 | #define NDNBOOST_LAMBDA_BE1(OPER_NAME, ACTION, CONSTA, CONSTB, CONVERSION) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 35 | template<class Arg, class B> \ |
| 36 | inline const \ |
| 37 | lambda_functor< \ |
| 38 | lambda_functor_base< \ |
| 39 | ACTION, \ |
| 40 | tuple<lambda_functor<Arg>, typename const_copy_argument <CONSTB>::type> \ |
| 41 | > \ |
| 42 | > \ |
| 43 | OPER_NAME (const lambda_functor<Arg>& a, CONSTB& b) { \ |
| 44 | return \ |
| 45 | lambda_functor_base< \ |
| 46 | ACTION, \ |
| 47 | tuple<lambda_functor<Arg>, typename const_copy_argument <CONSTB>::type>\ |
| 48 | > \ |
| 49 | (tuple<lambda_functor<Arg>, typename const_copy_argument <CONSTB>::type>(a, b)); \ |
| 50 | } |
| 51 | |
| 52 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 53 | #if defined NDNBOOST_LAMBDA_BE2 |
| 54 | #error "Multiple defines of NDNBOOST_LAMBDA_BE2" |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 55 | #endif |
| 56 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 57 | #define NDNBOOST_LAMBDA_BE2(OPER_NAME, ACTION, CONSTA, CONSTB, CONVERSION) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 58 | template<class A, class Arg> \ |
| 59 | inline const \ |
| 60 | lambda_functor< \ |
| 61 | lambda_functor_base< \ |
| 62 | ACTION, \ |
| 63 | tuple<typename CONVERSION <CONSTA>::type, lambda_functor<Arg> > \ |
| 64 | > \ |
| 65 | > \ |
| 66 | OPER_NAME (CONSTA& a, const lambda_functor<Arg>& b) { \ |
| 67 | return \ |
| 68 | lambda_functor_base< \ |
| 69 | ACTION, \ |
| 70 | tuple<typename CONVERSION <CONSTA>::type, lambda_functor<Arg> > \ |
| 71 | > \ |
| 72 | (tuple<typename CONVERSION <CONSTA>::type, lambda_functor<Arg> >(a, b)); \ |
| 73 | } |
| 74 | |
| 75 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 76 | #if defined NDNBOOST_LAMBDA_BE3 |
| 77 | #error "Multiple defines of NDNBOOST_LAMBDA_BE3" |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 78 | #endif |
| 79 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 80 | #define NDNBOOST_LAMBDA_BE3(OPER_NAME, ACTION, CONSTA, CONSTB, CONVERSION) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 81 | template<class ArgA, class ArgB> \ |
| 82 | inline const \ |
| 83 | lambda_functor< \ |
| 84 | lambda_functor_base< \ |
| 85 | ACTION, \ |
| 86 | tuple<lambda_functor<ArgA>, lambda_functor<ArgB> > \ |
| 87 | > \ |
| 88 | > \ |
| 89 | OPER_NAME (const lambda_functor<ArgA>& a, const lambda_functor<ArgB>& b) { \ |
| 90 | return \ |
| 91 | lambda_functor_base< \ |
| 92 | ACTION, \ |
| 93 | tuple<lambda_functor<ArgA>, lambda_functor<ArgB> > \ |
| 94 | > \ |
| 95 | (tuple<lambda_functor<ArgA>, lambda_functor<ArgB> >(a, b)); \ |
| 96 | } |
| 97 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 98 | #if defined NDNBOOST_LAMBDA_BE |
| 99 | #error "Multiple defines of NDNBOOST_LAMBDA_BE" |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 100 | #endif |
| 101 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 102 | #define NDNBOOST_LAMBDA_BE(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION) \ |
| 103 | NDNBOOST_LAMBDA_BE1(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION) \ |
| 104 | NDNBOOST_LAMBDA_BE2(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION) \ |
| 105 | NDNBOOST_LAMBDA_BE3(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 106 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 107 | #define NDNBOOST_LAMBDA_EMPTY() |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 108 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 109 | NDNBOOST_LAMBDA_BE(operator+, arithmetic_action<plus_action>, const A, const B, const_copy_argument) |
| 110 | NDNBOOST_LAMBDA_BE(operator-, arithmetic_action<minus_action>, const A, const B, const_copy_argument) |
| 111 | NDNBOOST_LAMBDA_BE(operator*, arithmetic_action<multiply_action>, const A, const B, const_copy_argument) |
| 112 | NDNBOOST_LAMBDA_BE(operator/, arithmetic_action<divide_action>, const A, const B, const_copy_argument) |
| 113 | NDNBOOST_LAMBDA_BE(operator%, arithmetic_action<remainder_action>, const A, const B, const_copy_argument) |
| 114 | NDNBOOST_LAMBDA_BE(operator<<, bitwise_action<leftshift_action>, const A, const B, const_copy_argument) |
| 115 | NDNBOOST_LAMBDA_BE(operator>>, bitwise_action<rightshift_action>, const A, const B, const_copy_argument) |
| 116 | NDNBOOST_LAMBDA_BE(operator&, bitwise_action<and_action>, const A, const B, const_copy_argument) |
| 117 | NDNBOOST_LAMBDA_BE(operator|, bitwise_action<or_action>, const A, const B, const_copy_argument) |
| 118 | NDNBOOST_LAMBDA_BE(operator^, bitwise_action<xor_action>, const A, const B, const_copy_argument) |
| 119 | NDNBOOST_LAMBDA_BE(operator&&, logical_action<and_action>, const A, const B, const_copy_argument) |
| 120 | NDNBOOST_LAMBDA_BE(operator||, logical_action<or_action>, const A, const B, const_copy_argument) |
| 121 | NDNBOOST_LAMBDA_BE(operator<, relational_action<less_action>, const A, const B, const_copy_argument) |
| 122 | NDNBOOST_LAMBDA_BE(operator>, relational_action<greater_action>, const A, const B, const_copy_argument) |
| 123 | NDNBOOST_LAMBDA_BE(operator<=, relational_action<lessorequal_action>, const A, const B, const_copy_argument) |
| 124 | NDNBOOST_LAMBDA_BE(operator>=, relational_action<greaterorequal_action>, const A, const B, const_copy_argument) |
| 125 | NDNBOOST_LAMBDA_BE(operator==, relational_action<equal_action>, const A, const B, const_copy_argument) |
| 126 | NDNBOOST_LAMBDA_BE(operator!=, relational_action<notequal_action>, const A, const B, const_copy_argument) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 127 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 128 | NDNBOOST_LAMBDA_BE(operator+=, arithmetic_assignment_action<plus_action>, A, const B, reference_argument) |
| 129 | NDNBOOST_LAMBDA_BE(operator-=, arithmetic_assignment_action<minus_action>, A, const B, reference_argument) |
| 130 | NDNBOOST_LAMBDA_BE(operator*=, arithmetic_assignment_action<multiply_action>, A, const B, reference_argument) |
| 131 | NDNBOOST_LAMBDA_BE(operator/=, arithmetic_assignment_action<divide_action>, A, const B, reference_argument) |
| 132 | NDNBOOST_LAMBDA_BE(operator%=, arithmetic_assignment_action<remainder_action>, A, const B, reference_argument) |
| 133 | NDNBOOST_LAMBDA_BE(operator<<=, bitwise_assignment_action<leftshift_action>, A, const B, reference_argument) |
| 134 | NDNBOOST_LAMBDA_BE(operator>>=, bitwise_assignment_action<rightshift_action>, A, const B, reference_argument) |
| 135 | NDNBOOST_LAMBDA_BE(operator&=, bitwise_assignment_action<and_action>, A, const B, reference_argument) |
| 136 | NDNBOOST_LAMBDA_BE(operator|=, bitwise_assignment_action<or_action>, A, const B, reference_argument) |
| 137 | NDNBOOST_LAMBDA_BE(operator^=, bitwise_assignment_action<xor_action>, A, const B, reference_argument) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 138 | |
| 139 | |
| 140 | // A special trick for comma operator for correct preprocessing |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 141 | #if defined NDNBOOST_LAMBDA_COMMA_OPERATOR_NAME |
| 142 | #error "Multiple defines of NDNBOOST_LAMBDA_COMMA_OPERATOR_NAME" |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 143 | #endif |
| 144 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 145 | #define NDNBOOST_LAMBDA_COMMA_OPERATOR_NAME operator, |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 146 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 147 | NDNBOOST_LAMBDA_BE1(NDNBOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const A, const B, const_copy_argument) |
| 148 | NDNBOOST_LAMBDA_BE2(NDNBOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const A, const B, const_copy_argument) |
| 149 | NDNBOOST_LAMBDA_BE3(NDNBOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const A, const B, const_copy_argument) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 150 | |
| 151 | |
| 152 | |
| 153 | namespace detail { |
| 154 | |
| 155 | // special cases for ostream& << Any and istream& >> Any --------------- |
| 156 | // the actual stream classes may vary and thus a specialisation for, |
| 157 | // say ostream& does not match (the general case above is chosen). |
| 158 | // Therefore we specialise for non-const reference: |
| 159 | // if the left argument is a stream, we store the stream as reference |
| 160 | // if it is something else, we store a const plain by default |
| 161 | |
| 162 | // Note that the overloading is const vs. non-const first argument |
| 163 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 164 | #ifdef NDNBOOST_NO_TEMPLATED_STREAMS |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 165 | template<class T> struct convert_ostream_to_ref_others_to_c_plain_by_default { |
| 166 | typedef typename detail::IF< |
| 167 | ndnboost::is_convertible<T*, std::ostream*>::value, |
| 168 | T&, |
| 169 | typename const_copy_argument <T>::type |
| 170 | >::RET type; |
| 171 | }; |
| 172 | |
| 173 | template<class T> struct convert_istream_to_ref_others_to_c_plain_by_default { |
| 174 | typedef typename detail::IF< |
| 175 | ndnboost::is_convertible<T*, std::istream*>::value, |
| 176 | T&, |
| 177 | typename const_copy_argument <T>::type |
| 178 | >::RET type; |
| 179 | }; |
| 180 | #else |
| 181 | |
| 182 | template<class T> struct convert_ostream_to_ref_others_to_c_plain_by_default { |
| 183 | typedef typename detail::IF< |
| 184 | is_instance_of_2< |
| 185 | T, std::basic_ostream |
| 186 | >::value, |
| 187 | T&, |
| 188 | typename const_copy_argument <T>::type |
| 189 | >::RET type; |
| 190 | }; |
| 191 | |
| 192 | template<class T> struct convert_istream_to_ref_others_to_c_plain_by_default { |
| 193 | typedef typename detail::IF< |
| 194 | is_instance_of_2< |
| 195 | T, std::basic_istream |
| 196 | >::value, |
| 197 | T&, |
| 198 | typename const_copy_argument <T>::type |
| 199 | >::RET type; |
| 200 | }; |
| 201 | #endif |
| 202 | |
| 203 | } // detail |
| 204 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 205 | NDNBOOST_LAMBDA_BE2(operator<<, bitwise_action< leftshift_action>, A, const B, detail::convert_ostream_to_ref_others_to_c_plain_by_default) |
| 206 | NDNBOOST_LAMBDA_BE2(operator>>, bitwise_action< rightshift_action>, A, const B, detail::convert_istream_to_ref_others_to_c_plain_by_default) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 207 | |
| 208 | |
| 209 | // special case for io_manipulators. |
| 210 | // function references cannot be given as arguments to lambda operator |
| 211 | // expressions in general. With << and >> the use of manipulators is |
| 212 | // so common, that specializations are provided to make them work. |
| 213 | |
| 214 | template<class Arg, class Ret, class ManipArg> |
| 215 | inline const |
| 216 | lambda_functor< |
| 217 | lambda_functor_base< |
| 218 | bitwise_action<leftshift_action>, |
| 219 | tuple<lambda_functor<Arg>, Ret(&)(ManipArg)> |
| 220 | > |
| 221 | > |
| 222 | operator<<(const lambda_functor<Arg>& a, Ret(&b)(ManipArg)) |
| 223 | { |
| 224 | return |
| 225 | lambda_functor_base< |
| 226 | bitwise_action<leftshift_action>, |
| 227 | tuple<lambda_functor<Arg>, Ret(&)(ManipArg)> |
| 228 | > |
| 229 | ( tuple<lambda_functor<Arg>, Ret(&)(ManipArg)>(a, b) ); |
| 230 | } |
| 231 | |
| 232 | template<class Arg, class Ret, class ManipArg> |
| 233 | inline const |
| 234 | lambda_functor< |
| 235 | lambda_functor_base< |
| 236 | bitwise_action<rightshift_action>, |
| 237 | tuple<lambda_functor<Arg>, Ret(&)(ManipArg)> |
| 238 | > |
| 239 | > |
| 240 | operator>>(const lambda_functor<Arg>& a, Ret(&b)(ManipArg)) |
| 241 | { |
| 242 | return |
| 243 | lambda_functor_base< |
| 244 | bitwise_action<rightshift_action>, |
| 245 | tuple<lambda_functor<Arg>, Ret(&)(ManipArg)> |
| 246 | > |
| 247 | ( tuple<lambda_functor<Arg>, Ret(&)(ManipArg)>(a, b) ); |
| 248 | } |
| 249 | |
| 250 | |
| 251 | // (+ and -) take their arguments as const references. |
| 252 | // This has consquences with pointer artihmetic |
| 253 | // E.g int a[]; ... *a = 1 works but not *(a+1) = 1. |
| 254 | // the result of a+1 would be const |
| 255 | // To make the latter work too, |
| 256 | // non-const arrays are taken as non-const and stored as non-const as well. |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 257 | #if defined NDNBOOST_LAMBDA_PTR_ARITHMETIC_E1 |
| 258 | #error "Multiple defines of NDNBOOST_LAMBDA_PTR_ARITHMETIC_E1" |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 259 | #endif |
| 260 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 261 | #define NDNBOOST_LAMBDA_PTR_ARITHMETIC_E1(OPER_NAME, ACTION, CONSTB) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 262 | template<class Arg, int N, class B> \ |
| 263 | inline const \ |
| 264 | lambda_functor< \ |
| 265 | lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONSTB(&)[N]> > \ |
| 266 | > \ |
| 267 | OPER_NAME (const lambda_functor<Arg>& a, CONSTB(&b)[N]) \ |
| 268 | { \ |
| 269 | return \ |
| 270 | lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONSTB(&)[N]> > \ |
| 271 | (tuple<lambda_functor<Arg>, CONSTB(&)[N]>(a, b)); \ |
| 272 | } |
| 273 | |
| 274 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 275 | #if defined NDNBOOST_LAMBDA_PTR_ARITHMETIC_E2 |
| 276 | #error "Multiple defines of NDNBOOST_LAMBDA_PTR_ARITHMETIC_E2" |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 277 | #endif |
| 278 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 279 | #define NDNBOOST_LAMBDA_PTR_ARITHMETIC_E2(OPER_NAME, ACTION, CONSTA) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 280 | template<int N, class A, class Arg> \ |
| 281 | inline const \ |
| 282 | lambda_functor< \ |
| 283 | lambda_functor_base<ACTION, tuple<CONSTA(&)[N], lambda_functor<Arg> > > \ |
| 284 | > \ |
| 285 | OPER_NAME (CONSTA(&a)[N], const lambda_functor<Arg>& b) \ |
| 286 | { \ |
| 287 | return \ |
| 288 | lambda_functor_base<ACTION, tuple<CONSTA(&)[N], lambda_functor<Arg> > > \ |
| 289 | (tuple<CONSTA(&)[N], lambda_functor<Arg> >(a, b)); \ |
| 290 | } |
| 291 | |
| 292 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 293 | NDNBOOST_LAMBDA_PTR_ARITHMETIC_E1(operator+, arithmetic_action<plus_action>, B) |
| 294 | NDNBOOST_LAMBDA_PTR_ARITHMETIC_E2(operator+, arithmetic_action<plus_action>, A) |
| 295 | NDNBOOST_LAMBDA_PTR_ARITHMETIC_E1(operator+, arithmetic_action<plus_action>,const B) |
| 296 | NDNBOOST_LAMBDA_PTR_ARITHMETIC_E2(operator+, arithmetic_action<plus_action>,const A) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 297 | |
| 298 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 299 | //NDNBOOST_LAMBDA_PTR_ARITHMETIC_E1(operator-, arithmetic_action<minus_action>) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 300 | // This is not needed, since the result of ptr-ptr is an rvalue anyway |
| 301 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 302 | NDNBOOST_LAMBDA_PTR_ARITHMETIC_E2(operator-, arithmetic_action<minus_action>, A) |
| 303 | NDNBOOST_LAMBDA_PTR_ARITHMETIC_E2(operator-, arithmetic_action<minus_action>, const A) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 304 | |
| 305 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 306 | #undef NDNBOOST_LAMBDA_BE1 |
| 307 | #undef NDNBOOST_LAMBDA_BE2 |
| 308 | #undef NDNBOOST_LAMBDA_BE3 |
| 309 | #undef NDNBOOST_LAMBDA_BE |
| 310 | #undef NDNBOOST_LAMBDA_COMMA_OPERATOR_NAME |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 311 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 312 | #undef NDNBOOST_LAMBDA_PTR_ARITHMETIC_E1 |
| 313 | #undef NDNBOOST_LAMBDA_PTR_ARITHMETIC_E2 |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 314 | |
| 315 | |
| 316 | // --------------------------------------------------------------------- |
| 317 | // unary operators ----------------------------------------------------- |
| 318 | // --------------------------------------------------------------------- |
| 319 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 320 | #if defined NDNBOOST_LAMBDA_UE |
| 321 | #error "Multiple defines of NDNBOOST_LAMBDA_UE" |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 322 | #endif |
| 323 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 324 | #define NDNBOOST_LAMBDA_UE(OPER_NAME, ACTION) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 325 | template<class Arg> \ |
| 326 | inline const \ |
| 327 | lambda_functor<lambda_functor_base<ACTION, tuple<lambda_functor<Arg> > > > \ |
| 328 | OPER_NAME (const lambda_functor<Arg>& a) \ |
| 329 | { \ |
| 330 | return \ |
| 331 | lambda_functor_base<ACTION, tuple<lambda_functor<Arg> > > \ |
| 332 | ( tuple<lambda_functor<Arg> >(a) ); \ |
| 333 | } |
| 334 | |
| 335 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 336 | NDNBOOST_LAMBDA_UE(operator+, unary_arithmetic_action<plus_action>) |
| 337 | NDNBOOST_LAMBDA_UE(operator-, unary_arithmetic_action<minus_action>) |
| 338 | NDNBOOST_LAMBDA_UE(operator~, bitwise_action<not_action>) |
| 339 | NDNBOOST_LAMBDA_UE(operator!, logical_action<not_action>) |
| 340 | NDNBOOST_LAMBDA_UE(operator++, pre_increment_decrement_action<increment_action>) |
| 341 | NDNBOOST_LAMBDA_UE(operator--, pre_increment_decrement_action<decrement_action>) |
| 342 | NDNBOOST_LAMBDA_UE(operator*, other_action<contentsof_action>) |
| 343 | NDNBOOST_LAMBDA_UE(operator&, other_action<addressof_action>) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 344 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 345 | #if defined NDNBOOST_LAMBDA_POSTFIX_UE |
| 346 | #error "Multiple defines of NDNBOOST_LAMBDA_POSTFIX_UE" |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 347 | #endif |
| 348 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 349 | #define NDNBOOST_LAMBDA_POSTFIX_UE(OPER_NAME, ACTION) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 350 | template<class Arg> \ |
| 351 | inline const \ |
| 352 | lambda_functor<lambda_functor_base<ACTION, tuple<lambda_functor<Arg> > > > \ |
| 353 | OPER_NAME (const lambda_functor<Arg>& a, int) \ |
| 354 | { \ |
| 355 | return \ |
| 356 | lambda_functor_base<ACTION, tuple<lambda_functor<Arg> > > \ |
| 357 | ( tuple<lambda_functor<Arg> >(a) ); \ |
| 358 | } |
| 359 | |
| 360 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 361 | NDNBOOST_LAMBDA_POSTFIX_UE(operator++, post_increment_decrement_action<increment_action>) |
| 362 | NDNBOOST_LAMBDA_POSTFIX_UE(operator--, post_increment_decrement_action<decrement_action>) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 363 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 364 | #undef NDNBOOST_LAMBDA_UE |
| 365 | #undef NDNBOOST_LAMBDA_POSTFIX_UE |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 366 | |
| 367 | } // namespace lambda |
| 368 | } // namespace ndnboost |
| 369 | |
| 370 | #endif |