File indexing completed on 2025-01-30 09:44:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_LAMBDA_OPERATORS_HPP
0014 #define BOOST_LAMBDA_OPERATORS_HPP
0015
0016 #include "boost/lambda/detail/is_instance_of.hpp"
0017
0018 namespace boost {
0019 namespace lambda {
0020
0021 #if defined BOOST_LAMBDA_BE1
0022 #error "Multiple defines of BOOST_LAMBDA_BE1"
0023 #endif
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #define BOOST_LAMBDA_BE1(OPER_NAME, ACTION, CONSTA, CONSTB, CONVERSION) \
0035 template<class Arg, class B> \
0036 inline const \
0037 lambda_functor< \
0038 lambda_functor_base< \
0039 ACTION, \
0040 tuple<lambda_functor<Arg>, typename const_copy_argument <CONSTB>::type> \
0041 > \
0042 > \
0043 OPER_NAME (const lambda_functor<Arg>& a, CONSTB& b) { \
0044 return \
0045 lambda_functor_base< \
0046 ACTION, \
0047 tuple<lambda_functor<Arg>, typename const_copy_argument <CONSTB>::type>\
0048 > \
0049 (tuple<lambda_functor<Arg>, typename const_copy_argument <CONSTB>::type>(a, b)); \
0050 }
0051
0052
0053 #if defined BOOST_LAMBDA_BE2
0054 #error "Multiple defines of BOOST_LAMBDA_BE2"
0055 #endif
0056
0057 #define BOOST_LAMBDA_BE2(OPER_NAME, ACTION, CONSTA, CONSTB, CONVERSION) \
0058 template<class A, class Arg> \
0059 inline const \
0060 lambda_functor< \
0061 lambda_functor_base< \
0062 ACTION, \
0063 tuple<typename CONVERSION <CONSTA>::type, lambda_functor<Arg> > \
0064 > \
0065 > \
0066 OPER_NAME (CONSTA& a, const lambda_functor<Arg>& b) { \
0067 return \
0068 lambda_functor_base< \
0069 ACTION, \
0070 tuple<typename CONVERSION <CONSTA>::type, lambda_functor<Arg> > \
0071 > \
0072 (tuple<typename CONVERSION <CONSTA>::type, lambda_functor<Arg> >(a, b)); \
0073 }
0074
0075
0076 #if defined BOOST_LAMBDA_BE3
0077 #error "Multiple defines of BOOST_LAMBDA_BE3"
0078 #endif
0079
0080 #define BOOST_LAMBDA_BE3(OPER_NAME, ACTION, CONSTA, CONSTB, CONVERSION) \
0081 template<class ArgA, class ArgB> \
0082 inline const \
0083 lambda_functor< \
0084 lambda_functor_base< \
0085 ACTION, \
0086 tuple<lambda_functor<ArgA>, lambda_functor<ArgB> > \
0087 > \
0088 > \
0089 OPER_NAME (const lambda_functor<ArgA>& a, const lambda_functor<ArgB>& b) { \
0090 return \
0091 lambda_functor_base< \
0092 ACTION, \
0093 tuple<lambda_functor<ArgA>, lambda_functor<ArgB> > \
0094 > \
0095 (tuple<lambda_functor<ArgA>, lambda_functor<ArgB> >(a, b)); \
0096 }
0097
0098 #if defined BOOST_LAMBDA_BE
0099 #error "Multiple defines of BOOST_LAMBDA_BE"
0100 #endif
0101
0102 #define BOOST_LAMBDA_BE(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION) \
0103 BOOST_LAMBDA_BE1(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION) \
0104 BOOST_LAMBDA_BE2(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION) \
0105 BOOST_LAMBDA_BE3(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION)
0106
0107 #define BOOST_LAMBDA_EMPTY()
0108
0109 BOOST_LAMBDA_BE(operator+, arithmetic_action<plus_action>, const A, const B, const_copy_argument)
0110 BOOST_LAMBDA_BE(operator-, arithmetic_action<minus_action>, const A, const B, const_copy_argument)
0111 BOOST_LAMBDA_BE(operator*, arithmetic_action<multiply_action>, const A, const B, const_copy_argument)
0112 BOOST_LAMBDA_BE(operator/, arithmetic_action<divide_action>, const A, const B, const_copy_argument)
0113 BOOST_LAMBDA_BE(operator%, arithmetic_action<remainder_action>, const A, const B, const_copy_argument)
0114 BOOST_LAMBDA_BE(operator<<, bitwise_action<leftshift_action>, const A, const B, const_copy_argument)
0115 BOOST_LAMBDA_BE(operator>>, bitwise_action<rightshift_action>, const A, const B, const_copy_argument)
0116 BOOST_LAMBDA_BE(operator&, bitwise_action<and_action>, const A, const B, const_copy_argument)
0117 BOOST_LAMBDA_BE(operator|, bitwise_action<or_action>, const A, const B, const_copy_argument)
0118 BOOST_LAMBDA_BE(operator^, bitwise_action<xor_action>, const A, const B, const_copy_argument)
0119 BOOST_LAMBDA_BE(operator&&, logical_action<and_action>, const A, const B, const_copy_argument)
0120 BOOST_LAMBDA_BE(operator||, logical_action<or_action>, const A, const B, const_copy_argument)
0121 BOOST_LAMBDA_BE(operator<, relational_action<less_action>, const A, const B, const_copy_argument)
0122 BOOST_LAMBDA_BE(operator>, relational_action<greater_action>, const A, const B, const_copy_argument)
0123 BOOST_LAMBDA_BE(operator<=, relational_action<lessorequal_action>, const A, const B, const_copy_argument)
0124 BOOST_LAMBDA_BE(operator>=, relational_action<greaterorequal_action>, const A, const B, const_copy_argument)
0125 BOOST_LAMBDA_BE(operator==, relational_action<equal_action>, const A, const B, const_copy_argument)
0126 BOOST_LAMBDA_BE(operator!=, relational_action<notequal_action>, const A, const B, const_copy_argument)
0127
0128 BOOST_LAMBDA_BE(operator+=, arithmetic_assignment_action<plus_action>, A, const B, reference_argument)
0129 BOOST_LAMBDA_BE(operator-=, arithmetic_assignment_action<minus_action>, A, const B, reference_argument)
0130 BOOST_LAMBDA_BE(operator*=, arithmetic_assignment_action<multiply_action>, A, const B, reference_argument)
0131 BOOST_LAMBDA_BE(operator/=, arithmetic_assignment_action<divide_action>, A, const B, reference_argument)
0132 BOOST_LAMBDA_BE(operator%=, arithmetic_assignment_action<remainder_action>, A, const B, reference_argument)
0133 BOOST_LAMBDA_BE(operator<<=, bitwise_assignment_action<leftshift_action>, A, const B, reference_argument)
0134 BOOST_LAMBDA_BE(operator>>=, bitwise_assignment_action<rightshift_action>, A, const B, reference_argument)
0135 BOOST_LAMBDA_BE(operator&=, bitwise_assignment_action<and_action>, A, const B, reference_argument)
0136 BOOST_LAMBDA_BE(operator|=, bitwise_assignment_action<or_action>, A, const B, reference_argument)
0137 BOOST_LAMBDA_BE(operator^=, bitwise_assignment_action<xor_action>, A, const B, reference_argument)
0138
0139
0140
0141 #if defined BOOST_LAMBDA_COMMA_OPERATOR_NAME
0142 #error "Multiple defines of BOOST_LAMBDA_COMMA_OPERATOR_NAME"
0143 #endif
0144
0145 #define BOOST_LAMBDA_COMMA_OPERATOR_NAME operator,
0146
0147 BOOST_LAMBDA_BE1(BOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const A, const B, const_copy_argument)
0148 BOOST_LAMBDA_BE2(BOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const A, const B, const_copy_argument)
0149 BOOST_LAMBDA_BE3(BOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const A, const B, const_copy_argument)
0150
0151
0152
0153 namespace detail {
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165 template<class T> struct convert_ostream_to_ref_others_to_c_plain_by_default {
0166 typedef typename detail::IF<
0167 is_instance_of_2<
0168 T, std::basic_ostream
0169 >::value,
0170 T&,
0171 typename const_copy_argument <T>::type
0172 >::RET type;
0173 };
0174
0175 template<class T> struct convert_istream_to_ref_others_to_c_plain_by_default {
0176 typedef typename detail::IF<
0177 is_instance_of_2<
0178 T, std::basic_istream
0179 >::value,
0180 T&,
0181 typename const_copy_argument <T>::type
0182 >::RET type;
0183 };
0184
0185 }
0186
0187 BOOST_LAMBDA_BE2(operator<<, bitwise_action< leftshift_action>, A, const B, detail::convert_ostream_to_ref_others_to_c_plain_by_default)
0188 BOOST_LAMBDA_BE2(operator>>, bitwise_action< rightshift_action>, A, const B, detail::convert_istream_to_ref_others_to_c_plain_by_default)
0189
0190
0191
0192
0193
0194
0195
0196 template<class Arg, class Ret, class ManipArg>
0197 inline const
0198 lambda_functor<
0199 lambda_functor_base<
0200 bitwise_action<leftshift_action>,
0201 tuple<lambda_functor<Arg>, Ret(&)(ManipArg)>
0202 >
0203 >
0204 operator<<(const lambda_functor<Arg>& a, Ret(&b)(ManipArg))
0205 {
0206 return
0207 lambda_functor_base<
0208 bitwise_action<leftshift_action>,
0209 tuple<lambda_functor<Arg>, Ret(&)(ManipArg)>
0210 >
0211 ( tuple<lambda_functor<Arg>, Ret(&)(ManipArg)>(a, b) );
0212 }
0213
0214 template<class Arg, class Ret, class ManipArg>
0215 inline const
0216 lambda_functor<
0217 lambda_functor_base<
0218 bitwise_action<rightshift_action>,
0219 tuple<lambda_functor<Arg>, Ret(&)(ManipArg)>
0220 >
0221 >
0222 operator>>(const lambda_functor<Arg>& a, Ret(&b)(ManipArg))
0223 {
0224 return
0225 lambda_functor_base<
0226 bitwise_action<rightshift_action>,
0227 tuple<lambda_functor<Arg>, Ret(&)(ManipArg)>
0228 >
0229 ( tuple<lambda_functor<Arg>, Ret(&)(ManipArg)>(a, b) );
0230 }
0231
0232
0233
0234
0235
0236
0237
0238
0239 #if defined BOOST_LAMBDA_PTR_ARITHMETIC_E1
0240 #error "Multiple defines of BOOST_LAMBDA_PTR_ARITHMETIC_E1"
0241 #endif
0242
0243 #define BOOST_LAMBDA_PTR_ARITHMETIC_E1(OPER_NAME, ACTION, CONSTB) \
0244 template<class Arg, int N, class B> \
0245 inline const \
0246 lambda_functor< \
0247 lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONSTB(&)[N]> > \
0248 > \
0249 OPER_NAME (const lambda_functor<Arg>& a, CONSTB(&b)[N]) \
0250 { \
0251 return \
0252 lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONSTB(&)[N]> > \
0253 (tuple<lambda_functor<Arg>, CONSTB(&)[N]>(a, b)); \
0254 }
0255
0256
0257 #if defined BOOST_LAMBDA_PTR_ARITHMETIC_E2
0258 #error "Multiple defines of BOOST_LAMBDA_PTR_ARITHMETIC_E2"
0259 #endif
0260
0261 #define BOOST_LAMBDA_PTR_ARITHMETIC_E2(OPER_NAME, ACTION, CONSTA) \
0262 template<int N, class A, class Arg> \
0263 inline const \
0264 lambda_functor< \
0265 lambda_functor_base<ACTION, tuple<CONSTA(&)[N], lambda_functor<Arg> > > \
0266 > \
0267 OPER_NAME (CONSTA(&a)[N], const lambda_functor<Arg>& b) \
0268 { \
0269 return \
0270 lambda_functor_base<ACTION, tuple<CONSTA(&)[N], lambda_functor<Arg> > > \
0271 (tuple<CONSTA(&)[N], lambda_functor<Arg> >(a, b)); \
0272 }
0273
0274
0275 BOOST_LAMBDA_PTR_ARITHMETIC_E1(operator+, arithmetic_action<plus_action>, B)
0276 BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator+, arithmetic_action<plus_action>, A)
0277 BOOST_LAMBDA_PTR_ARITHMETIC_E1(operator+, arithmetic_action<plus_action>,const B)
0278 BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator+, arithmetic_action<plus_action>,const A)
0279
0280
0281
0282
0283
0284 BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator-, arithmetic_action<minus_action>, A)
0285 BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator-, arithmetic_action<minus_action>, const A)
0286
0287
0288 #undef BOOST_LAMBDA_BE1
0289 #undef BOOST_LAMBDA_BE2
0290 #undef BOOST_LAMBDA_BE3
0291 #undef BOOST_LAMBDA_BE
0292 #undef BOOST_LAMBDA_COMMA_OPERATOR_NAME
0293
0294 #undef BOOST_LAMBDA_PTR_ARITHMETIC_E1
0295 #undef BOOST_LAMBDA_PTR_ARITHMETIC_E2
0296
0297
0298
0299
0300
0301
0302 #if defined BOOST_LAMBDA_UE
0303 #error "Multiple defines of BOOST_LAMBDA_UE"
0304 #endif
0305
0306 #define BOOST_LAMBDA_UE(OPER_NAME, ACTION) \
0307 template<class Arg> \
0308 inline const \
0309 lambda_functor<lambda_functor_base<ACTION, tuple<lambda_functor<Arg> > > > \
0310 OPER_NAME (const lambda_functor<Arg>& a) \
0311 { \
0312 return \
0313 lambda_functor_base<ACTION, tuple<lambda_functor<Arg> > > \
0314 ( tuple<lambda_functor<Arg> >(a) ); \
0315 }
0316
0317
0318 BOOST_LAMBDA_UE(operator+, unary_arithmetic_action<plus_action>)
0319 BOOST_LAMBDA_UE(operator-, unary_arithmetic_action<minus_action>)
0320 BOOST_LAMBDA_UE(operator~, bitwise_action<not_action>)
0321 BOOST_LAMBDA_UE(operator!, logical_action<not_action>)
0322 BOOST_LAMBDA_UE(operator++, pre_increment_decrement_action<increment_action>)
0323 BOOST_LAMBDA_UE(operator--, pre_increment_decrement_action<decrement_action>)
0324 BOOST_LAMBDA_UE(operator*, other_action<contentsof_action>)
0325 BOOST_LAMBDA_UE(operator&, other_action<addressof_action>)
0326
0327 #if defined BOOST_LAMBDA_POSTFIX_UE
0328 #error "Multiple defines of BOOST_LAMBDA_POSTFIX_UE"
0329 #endif
0330
0331 #define BOOST_LAMBDA_POSTFIX_UE(OPER_NAME, ACTION) \
0332 template<class Arg> \
0333 inline const \
0334 lambda_functor<lambda_functor_base<ACTION, tuple<lambda_functor<Arg> > > > \
0335 OPER_NAME (const lambda_functor<Arg>& a, int) \
0336 { \
0337 return \
0338 lambda_functor_base<ACTION, tuple<lambda_functor<Arg> > > \
0339 ( tuple<lambda_functor<Arg> >(a) ); \
0340 }
0341
0342
0343 BOOST_LAMBDA_POSTFIX_UE(operator++, post_increment_decrement_action<increment_action>)
0344 BOOST_LAMBDA_POSTFIX_UE(operator--, post_increment_decrement_action<decrement_action>)
0345
0346 #undef BOOST_LAMBDA_UE
0347 #undef BOOST_LAMBDA_POSTFIX_UE
0348
0349 }
0350 }
0351
0352 #endif