📄 operator.h.m4
字号:
struct not_equal_to {};struct subscript {};struct assign {};struct pre_increment {};struct pre_decrement {};struct negate {};struct not_ {};struct address {};struct dereference {};struct reinterpret_ {};struct static_ {};struct dynamic_ {};template <class T_action, class T_test1, class T_test2>struct lambda_action_deduce_result_type { typedef typename type_trait<T_test1>::type type; }; // TODO: e.g. T_test1=int, T_test2=double yields int but it should yield double !template <class T_action, class T_test1, class T_test2>struct lambda_action_deduce_result_type<logical<T_action>, T_test1, T_test2> { typedef bool type; };template <class T_action, class T_test1, class T_test2>struct lambda_action_deduce_result_type<relational<T_action>, T_test1, T_test2> { typedef bool type; };template <class T_action, class T_test1, class T_test2>struct lambda_action_deduce_result_type<arithmetic_assign<T_action>, T_test1, T_test2> { typedef T_test1 type; };template <class T_action, class T_test1, class T_test2>struct lambda_action_deduce_result_type<bitwise_assign<T_action>, T_test1, T_test2> { typedef T_test1 type; };template <class T_test1, class T_test2>struct lambda_action_deduce_result_type<other<subscript>, T_test1, T_test2> { typedef typename type_trait<typename dereference_trait<T_test1>::type>::pass type; };template <class T_action, class T_test>struct lambda_action_unary_deduce_result_type { typedef typename type_trait<T_test>::type type; };template <class T_action, class T_type, class T_test>struct lambda_action_convert_deduce_result_type { typedef typename type_trait<T_type>::type type; };template <class T_action, class T_test>struct lambda_action_unary_deduce_result_type<unary_logical<T_action>, T_test> { typedef bool type; };template <class T_test>struct lambda_action_unary_deduce_result_type<unary_other<address>, T_test> { typedef typename type_trait<T_test>::pointer type; };template <class T_test>struct lambda_action_unary_deduce_result_type<unary_other<dereference>, T_test> { typedef typename type_trait<typename dereference_trait<T_test>::type>::pass type; };LAMBDA_OPERATOR(arithmetic<plus>,+)dnlLAMBDA_OPERATOR(arithmetic<minus>,-)dnlLAMBDA_OPERATOR(arithmetic<multiplies>,*)dnlLAMBDA_OPERATOR(arithmetic<divides>,/)dnlLAMBDA_OPERATOR(arithmetic<modulus>,%)dnlLAMBDA_OPERATOR(bitwise<leftshift>,<<)dnlLAMBDA_OPERATOR(bitwise<rightshift>,>>)dnlLAMBDA_OPERATOR(bitwise<and_>,&)dnlLAMBDA_OPERATOR(bitwise<or_>,|)dnlLAMBDA_OPERATOR(bitwise<xor_>,^)dnlLAMBDA_OPERATOR(logical<and_>,&&)dnlLAMBDA_OPERATOR(logical<or_>,||)dnlLAMBDA_OPERATOR(relational<less>,<)dnlLAMBDA_OPERATOR(relational<greater>,>)dnlLAMBDA_OPERATOR(relational<less_equal>,<=)dnlLAMBDA_OPERATOR(relational<greater_equal>,>=)dnlLAMBDA_OPERATOR(relational<equal_to>,==)dnlLAMBDA_OPERATOR(relational<not_equal_to>,!=)dnlLAMBDA_OPERATOR(arithmetic_assign<plus>,+=)dnlLAMBDA_OPERATOR(arithmetic_assign<minus>,-=)dnlLAMBDA_OPERATOR(arithmetic_assign<multiplies>,*=)dnlLAMBDA_OPERATOR(arithmetic_assign<divides>,/=)dnlLAMBDA_OPERATOR(arithmetic_assign<modulus>,%=)dnlLAMBDA_OPERATOR(bitwise_assign<leftshift>,<<=)dnlLAMBDA_OPERATOR(bitwise_assign<rightshift>,>>=)dnlLAMBDA_OPERATOR(bitwise_assign<and_>,&=)dnlLAMBDA_OPERATOR(bitwise_assign<or_>,|=)dnlLAMBDA_OPERATOR(bitwise_assign<xor_>,^=)dnldivert(1)dnltemplate <>struct lambda_action<other<subscript> >{ template <class T_arg1, class T_arg2> static typename lambda_action_deduce_result_type<other<subscript>, T_arg1, T_arg2>::type do_action(T_arg1 _A_1, T_arg2 _A_2) { return _A_1[[_A_2]]; }};template <>struct lambda_action<other<assign> >{ template <class T_arg1, class T_arg2> static typename lambda_action_deduce_result_type<other<assign>, T_arg1, T_arg2>::type do_action(T_arg1 _A_1, T_arg2 _A_2) { return _A_1 = _A_2; }};divert(0)dnlLAMBDA_OPERATOR_UNARY(unary_arithmetic<pre_increment>,++)dnlLAMBDA_OPERATOR_UNARY(unary_arithmetic<pre_decrement>,--)dnlLAMBDA_OPERATOR_UNARY(unary_arithmetic<negate>,-)dnlLAMBDA_OPERATOR_UNARY(unary_bitwise<not_>,~)dnlLAMBDA_OPERATOR_UNARY(unary_logical<not_>,!)dnlLAMBDA_OPERATOR_UNARY(unary_other<address>,&)dnlLAMBDA_OPERATOR_UNARY(unary_other<dereference>,*)dnlLAMBDA_OPERATOR_CONVERT(cast_<reinterpret_>,reinterpret_cast)dnlLAMBDA_OPERATOR_CONVERT(cast_<static_>,static_cast)dnlLAMBDA_OPERATOR_CONVERT(cast_<dynamic_>,dynamic_cast)dnltemplate <class T_action>struct lambda_action {};template <class T_action>struct lambda_action_unary {};template <class T_action, class T_type>struct lambda_action_convert {};undivert(1)template <class T_action, class T_type1, class T_type2>struct lambda_operator : public lambda_base{ typedef typename lambda<T_type1>::lambda_type arg1_type; typedef typename lambda<T_type2>::lambda_type arg2_type; template <LOOP(class T_arg%1=void,CALL_SIZE)> struct deduce_result_type { typedef typename arg1_type::template deduce_result_type<LOOP(_P_(T_arg%1),CALL_SIZE)>::type left_type; typedef typename arg2_type::template deduce_result_type<LOOP(_P_(T_arg%1),CALL_SIZE)>::type right_type; typedef typename lambda_action_deduce_result_type<T_action, left_type, right_type>::type type; }; typedef typename lambda_action_deduce_result_type< T_action, typename arg1_type::result_type, typename arg2_type::result_type >::type result_type; result_type operator ()() const;FOR(1, CALL_SIZE,[[LAMBDA_OPERATOR_DO]](%1))dnl lambda_operator(_R_(T_type1) a1, _R_(T_type2) a2 ) : arg1_(a1), arg2_(a2) {} arg1_type arg1_; arg2_type arg2_;};template <class T_action, class T_type1, class T_type2>typename lambda_operator<T_action, T_type1, T_type2>::result_typelambda_operator<T_action, T_type1, T_type2>::operator ()() const { return lambda_action<T_action>::template do_action< typename arg1_type::result_type, typename arg2_type::result_type> (arg1_(), arg2_()); }template <class T_action, class T_lambda_action, class T_arg1, class T_arg2>void visit_each(const T_action& _A_action, const lambda_operator<T_lambda_action, T_arg1, T_arg2>& _A_target){ visit_each(_A_action, _A_target.arg1_); visit_each(_A_action, _A_target.arg2_);}template <class T_action, class T_type>struct lambda_operator_unary : public lambda_base{ typedef typename lambda<T_type>::lambda_type arg_type; template <LOOP(class T_arg%1=void,CALL_SIZE)> struct deduce_result_type { typedef typename arg_type::template deduce_result_type<LOOP(_P_(T_arg%1),CALL_SIZE)>::type operand_type; typedef typename lambda_action_unary_deduce_result_type<T_action, operand_type>::type type; }; typedef typename lambda_action_unary_deduce_result_type< T_action, typename arg_type::result_type >::type result_type; result_type operator ()() const;FOR(1, CALL_SIZE,[[LAMBDA_OPERATOR_UNARY_DO]](%1))dnl lambda_operator_unary(_R_(T_type) a) : arg_(a) {} arg_type arg_;};template <class T_action, class T_type>typename lambda_operator_unary<T_action, T_type>::result_typelambda_operator_unary<T_action, T_type>::operator ()() const { return lambda_action_unary<T_action>::template do_action< typename arg_type::result_type> (arg_()); }template <class T_action, class T_lambda_action, class T_arg>void visit_each(const T_action& _A_action, const lambda_operator_unary<T_lambda_action, T_arg>& _A_target){ visit_each(_A_action, _A_target.arg_);}template <class T_action, class T_type, class T_arg>struct lambda_operator_convert : public lambda_base{ typedef typename lambda<T_arg>::lambda_type arg_type; template <LOOP(class T_arg%1=void,CALL_SIZE)> struct deduce_result_type { typedef typename arg_type::template deduce_result_type<LOOP(_P_(T_arg%1),CALL_SIZE)>::type operand_type; typedef typename lambda_action_convert_deduce_result_type<T_action, T_type, operand_type>::type type; }; typedef typename lambda_action_convert_deduce_result_type< T_action, T_type, typename arg_type::result_type >::type result_type; result_type operator ()() const;FOR(1, CALL_SIZE,[[LAMBDA_OPERATOR_CONVERT_DO]](%1))dnl lambda_operator_convert(_R_(T_arg) a) : arg_(a) {} arg_type arg_;};template <class T_action, class T_type, class T_arg>typename lambda_operator_convert<T_action, T_type, T_arg>::result_typelambda_operator_convert<T_action, T_type, T_arg>::operator ()() const { return lambda_action_convert<T_action, T_type>::template do_action< typename arg_type::result_type> (arg_()); }template <class T_action, class T_lambda_action, class T_type, class T_arg>void visit_each(const T_action& _A_action, const lambda_operator_convert<T_lambda_action, T_type, T_arg>& _A_target){ visit_each(_A_action, _A_target.arg_);}undivert(2)dnl} /* namespace sigc */#endif /* _SIGC_LAMBDA_OPERATOR_HPP_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -