📄 operator.h.m4
字号:
dnl Copyright 2002, The libsigc++ Development Team dnl dnl This library is free software; you can redistribute it and/or dnl modify it under the terms of the GNU Lesser General Public dnl License as published by the Free Software Foundation; either dnl version 2.1 of the License, or (at your option) any later version. dnl dnl This library is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl Lesser General Public License for more details. dnl dnl You should have received a copy of the GNU Lesser General Public dnl License along with this library; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA dnldivert(-1)include(template.macros.m4)dnl dnl Macros to make operatorsdefine([LAMBDA_OPERATOR_DO],[dnl template <LOOP(class T_arg%1, $1)> typename deduce_result_type<LOOP(T_arg%1,$1)>::type operator ()(LOOP(T_arg%1 _A_%1, $1)) const { return lambda_action<T_action>::template do_action< typename deduce_result_type<LOOP(_P_(T_arg%1),$1)>::left_type, typename deduce_result_type<LOOP(_P_(T_arg%1),$1)>::right_type> (arg1_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)> (LOOP(_A_%1, $1)), arg2_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)> (LOOP(_A_%1, $1))); } #ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD template <LOOP(class T_arg%1, $1)> typename deduce_result_type<LOOP(T_arg%1,$1)>::type sun_forte_workaround(LOOP(T_arg%1 _A_%1, $1)) const { return lambda_action<T_action>::template do_action< typename deduce_result_type<LOOP(_P_(T_arg%1),$1)>::left_type, typename deduce_result_type<LOOP(_P_(T_arg%1),$1)>::right_type> (arg1_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)> (LOOP(_A_%1, $1)), arg2_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)> (LOOP(_A_%1, $1))); } #endif //SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD])dnldefine([LAMBDA_OPERATOR_UNARY_DO],[dnl template <LOOP(class T_arg%1, $1)> typename deduce_result_type<LOOP(T_arg%1,$1)>::type operator ()(LOOP(T_arg%1 _A_%1, $1)) const { return lambda_action_unary<T_action>::template do_action< typename deduce_result_type<LOOP(_P_(T_arg%1),$1)>::operand_type> (arg_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)> (LOOP(_A_%1, $1))); } #ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD template <LOOP(class T_arg%1, $1)> typename deduce_result_type<LOOP(T_arg%1,$1)>::type sun_forte_workaround(LOOP(T_arg%1 _A_%1, $1)) const { return lambda_action_unary<T_action>::template do_action< typename deduce_result_type<LOOP(_P_(T_arg%1),$1)>::operand_type> (arg_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)> (LOOP(_A_%1, $1))); } #endif])dnldefine([LAMBDA_OPERATOR_CONVERT_DO],[dnl template <LOOP(class T_arg%1, $1)> typename deduce_result_type<LOOP(T_arg%1,$1)>::type operator ()(LOOP(T_arg%1 _A_%1, $1)) const { return lambda_action_convert<T_action, T_type>::template do_action< typename deduce_result_type<LOOP(_P_(T_arg%1),$1)>::operand_type> (arg_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)> (LOOP(_A_%1, $1))); } #ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD template <LOOP(class T_arg%1, $1)> typename deduce_result_type<LOOP(T_arg%1,$1)>::type sun_forte_workaround(LOOP(T_arg%1 _A_%1, $1)) const { return lambda_action_convert<T_action, T_type>::template do_action< typename deduce_result_type<LOOP(_P_(T_arg%1),$1)>::operand_type> (arg_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)> (LOOP(_A_%1, $1))); } #endif])dnldefine([LAMBDA_OPERATOR],[dnldivert(1)dnltemplate <>struct lambda_action<$1 >{ template <class T_arg1, class T_arg2> static typename lambda_action_deduce_result_type<$1, T_arg1, T_arg2>::type do_action(T_arg1 _A_1, T_arg2 _A_2) { return _A_1 $2 _A_2; }};divert(2)dnl// Operators for lambda action $1. At least one of the arguments needs to be of type lamdba, hence the overloads.template <class T_arg1, class T_arg2>lambda<lambda_operator<$1, T_arg1, T_arg2> >operator $2 (const lambda<T_arg1>& a1, const lambda<T_arg2>& a2){ typedef lambda_operator<$1, T_arg1, T_arg2> operator_type; return lambda<operator_type>(operator_type(a1.value_,a2.value_)); }template <class T_arg1, class T_arg2>lambda<lambda_operator<$1, T_arg1, typename unwrap_reference<T_arg2>::type> >operator $2 (const lambda<T_arg1>& a1, const T_arg2& a2){ typedef lambda_operator<$1, T_arg1, typename unwrap_reference<T_arg2>::type> operator_type; return lambda<operator_type>(operator_type(a1.value_,a2)); }template <class T_arg1, class T_arg2>lambda<lambda_operator<$1, typename unwrap_reference<T_arg1>::type, T_arg2> >operator $2 (const T_arg1& a1, const lambda<T_arg2>& a2){ typedef lambda_operator<$1, typename unwrap_reference<T_arg1>::type, T_arg2> operator_type; return lambda<operator_type>(operator_type(a1,a2.value_)); }divert(0)dnl])define([LAMBDA_OPERATOR_UNARY],[dnldivert(1)dnltemplate <>struct lambda_action_unary<$1 >{ template <class T_arg> static typename lambda_action_unary_deduce_result_type<$1, T_arg>::type do_action(T_arg _Aa) { return $2[]_Aa; }};divert(2)dnl// Operator for lambda action $1.template <class T_arg>lambda<lambda_operator_unary<$1, T_arg> >operator $2 (const lambda<T_arg>& a){ typedef lambda_operator_unary<$1, T_arg> operator_type; return lambda<operator_type>(operator_type(a.value_)); }divert(0)dnl])define([LAMBDA_OPERATOR_CONVERT],[dnldivert(1)dnltemplate <class T_type>struct lambda_action_convert<$1, T_type>{ template <class T_arg> static typename lambda_action_convert_deduce_result_type<$1, T_type, T_arg>::type do_action(T_arg _Aa) { return $2<T_type>(_Aa); }};divert(2)dnl// Creators for lambda action $1.template <class T_type, class T_arg>lambda<lambda_operator_convert<$1, T_type, typename unwrap_lambda_type<T_arg>::type> >$2_(const T_arg& a){ typedef lambda_operator_convert<$1, T_type, typename unwrap_lambda_type<T_arg>::type> operator_type; return lambda<operator_type>(operator_type(unwrap_lambda_value(a))); }divert(0)dnl])divert(0)dnl#ifndef _SIGC_LAMBDA_OPERATOR_HPP_#define _SIGC_LAMBDA_OPERATOR_HPP_#include <sigc++/adaptors/lambda/base.h>namespace sigc {/** Deduces the base type of a reference or a pointer. * @ingroup internal */template <class T_type>struct dereference_trait { typedef void type; };template <class T_type>struct dereference_trait<T_type*> { typedef T_type type; };template <class T_type>struct dereference_trait<const T_type*> { typedef const T_type type; };template <class T_type>struct dereference_trait<T_type*&> { typedef T_type type; };template <class T_type>struct dereference_trait<const T_type*&> { typedef const T_type type; };template <class T_type>struct dereference_trait<T_type* const&> { typedef T_type type; };template <class T_type>struct dereference_trait<const T_type* const&> { typedef const T_type type; };template <class T_type>struct arithmetic {};template <class T_type>struct bitwise {};template <class T_type>struct logical {};template <class T_type>struct relational {};template <class T_type>struct arithmetic_assign {};template <class T_type>struct bitwise_assign {};template <class T_type>struct other {};template <class T_type>struct unary_arithmetic {};template <class T_type>struct unary_bitwise {};template <class T_type>struct unary_logical {};template <class T_type>struct unary_other {};template <class T_type>struct cast_ {};struct plus {};struct minus {};struct multiplies {};struct divides {};struct modulus {};struct leftshift {};struct rightshift {};struct and_ {};struct or_ {};struct xor_ {};struct less {};struct greater {};struct less_equal {};struct greater_equal {};struct equal_to {};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -