|
|
|
|
| #ifndef _CLI_FUNCTIONAL_
|
| #define _CLI_FUNCTIONAL_
|
| #include <cliext/xutility>
|
|
|
| namespace cliext {
|
|
|
|
|
|
|
|
|
|
|
|
|
| generic<typename TArg,
|
| typename TResult>
|
| delegate TResult unary_delegate(TArg);
|
|
|
|
|
|
|
| generic<typename TArg>
|
| delegate void unary_delegate_noreturn(TArg);
|
|
|
|
|
|
|
|
|
| generic<typename TArg1,
|
| typename TArg2,
|
| typename TResult>
|
| delegate TResult binary_delegate(TArg1, TArg2);
|
|
|
|
|
|
|
|
|
| generic<typename TArg1,
|
| typename TArg2>
|
| delegate void binary_delegate_noreturn(TArg1, TArg2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t,
|
| typename _Result_t>
|
| ref class unary_function
|
| {
|
| public:
|
| typedef _Arg_t argument_type;
|
| typedef _Result_t result_type;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg1_t,
|
| typename _Arg2_t,
|
| typename _Result_t>
|
| ref class binary_function
|
| {
|
| public:
|
| typedef _Arg1_t first_argument_type;
|
| typedef _Arg2_t second_argument_type;
|
| typedef _Result_t result_type;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_logical_not
|
| : public unary_function<_Arg_t, bool>
|
| {
|
| public:
|
| typedef unary_function<_Arg_t, bool> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::argument_type argument_type;
|
|
|
| static result_type function(argument_type _Left)
|
| {
|
| return (!_Left);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_negate
|
| : public unary_function<_Arg_t, _Arg_t>
|
| {
|
| public:
|
| typedef unary_function<_Arg_t, _Arg_t> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::argument_type argument_type;
|
|
|
| static result_type function(argument_type _Left)
|
| {
|
| return (-_Left);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_plus
|
| : public binary_function<_Arg_t, _Arg_t, _Arg_t>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, _Arg_t> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left + _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_minus
|
| : public binary_function<_Arg_t, _Arg_t, _Arg_t>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, _Arg_t> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left - _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_multiplies
|
| : public binary_function<_Arg_t, _Arg_t, _Arg_t>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, _Arg_t> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left * _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_divides
|
| : public binary_function<_Arg_t, _Arg_t, _Arg_t>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, _Arg_t> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left / _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_modulus
|
| : public binary_function<_Arg_t, _Arg_t, _Arg_t>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, _Arg_t> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left % _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_equal_to
|
| : public binary_function<_Arg_t, _Arg_t, bool>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, bool> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left == _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_not_equal_to
|
| : public binary_function<_Arg_t, _Arg_t, bool>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, bool> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left != _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_less
|
| : public binary_function<_Arg_t, _Arg_t, bool>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, bool> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left < _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_greater_equal
|
| : public binary_function<_Arg_t, _Arg_t, bool>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, bool> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left >= _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_greater
|
| : public binary_function<_Arg_t, _Arg_t, bool>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, bool> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left > _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_less_equal
|
| : public binary_function<_Arg_t, _Arg_t, bool>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, bool> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left <= _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_logical_and
|
| : public binary_function<_Arg_t, _Arg_t, bool>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, bool> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left && _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class ref_logical_or
|
| : public binary_function<_Arg_t, _Arg_t, bool>
|
| {
|
| public:
|
| typedef binary_function<_Arg_t, _Arg_t, bool> _Mybase_t;
|
| typedef typename _Mybase_t::result_type result_type;
|
| typedef typename _Mybase_t::first_argument_type first_argument_type;
|
| typedef typename _Mybase_t::second_argument_type second_argument_type;
|
|
|
| static result_type function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (_Left || _Right);
|
| }
|
| };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| template<typename _Ref_t>
|
| ref class _Unary_fun
|
| {
|
| public:
|
| typedef _Ref_t ref_type;
|
| typedef typename ref_type::argument_type argument_type;
|
| typedef typename ref_type::result_type result_type;
|
| typedef _STLCLR UnaryDelegate<argument_type, result_type>
|
| delegate_type;
|
|
|
| result_type operator()(argument_type _Left)
|
| {
|
| return (ref_type::function(_Left));
|
| }
|
|
|
| operator delegate_type^()
|
| {
|
| return (gcnew delegate_type(&ref_type::function));
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Ref_t>
|
| ref class _Unary_fun_noreturn
|
| {
|
| public:
|
| typedef _Ref_t ref_type;
|
| typedef typename ref_type::argument_type argument_type;
|
| typedef void result_type;
|
| typedef unary_delegate_noreturn<argument_type>
|
| delegate_type;
|
|
|
| result_type operator()(argument_type _Left)
|
| {
|
| return (ref_type::function(_Left));
|
| }
|
|
|
| operator delegate_type^()
|
| {
|
| return (gcnew delegate_type(&ref_type::function));
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Ref_t>
|
| ref class _Binary_fun
|
| {
|
| public:
|
| typedef _Ref_t ref_type;
|
| typedef typename ref_type::first_argument_type first_argument_type;
|
| typedef typename ref_type::second_argument_type second_argument_type;
|
| typedef typename ref_type::result_type result_type;
|
| typedef _STLCLR BinaryDelegate<
|
| first_argument_type, second_argument_type, result_type>
|
| delegate_type;
|
|
|
| result_type operator()(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (ref_type::function(_Left, _Right));
|
| }
|
|
|
| operator delegate_type^()
|
| {
|
| return (gcnew delegate_type(&ref_type::function));
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Ref_t>
|
| ref class _Binary_fun_noreturn
|
| {
|
| public:
|
| typedef _Ref_t ref_type;
|
| typedef typename ref_type::first_argument_type first_argument_type;
|
| typedef typename ref_type::second_argument_type second_argument_type;
|
| typedef void result_type;
|
| typedef binary_delegate_noreturn<
|
| first_argument_type, second_argument_type>
|
| delegate_type;
|
|
|
| result_type operator()(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (ref_type::function(_Left, _Right));
|
| }
|
|
|
| operator delegate_type^()
|
| {
|
| return (gcnew delegate_type(&ref_type::function));
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class logical_not
|
| : public _Unary_fun< ref_logical_not<_Arg_t> >
|
| {
|
| public:
|
| typedef logical_not _Mytype_t;
|
|
|
| logical_not()
|
| {
|
| }
|
|
|
| logical_not(logical_not%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class negate
|
| : public _Unary_fun< ref_negate<_Arg_t> >
|
| {
|
| public:
|
| typedef negate _Mytype_t;
|
|
|
| negate()
|
| {
|
| }
|
|
|
| negate(negate%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class plus
|
| : public _Binary_fun< ref_plus<_Arg_t> >
|
| {
|
| public:
|
| typedef plus _Mytype_t;
|
|
|
| plus()
|
| {
|
| }
|
|
|
| plus(plus%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class minus
|
| : public _Binary_fun< ref_minus<_Arg_t> >
|
| {
|
| public:
|
| typedef minus _Mytype_t;
|
|
|
| minus()
|
| {
|
| }
|
|
|
| minus(minus%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class multiplies
|
| : public _Binary_fun< ref_multiplies<_Arg_t> >
|
| {
|
| public:
|
| typedef multiplies _Mytype_t;
|
|
|
| multiplies()
|
| {
|
| }
|
|
|
| multiplies(multiplies%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class divides
|
| : public _Binary_fun< ref_divides<_Arg_t> >
|
| {
|
| public:
|
| typedef divides _Mytype_t;
|
|
|
| divides()
|
| {
|
| }
|
|
|
| divides(divides%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class modulus
|
| : public _Binary_fun< ref_modulus<_Arg_t> >
|
| {
|
| public:
|
| typedef modulus _Mytype_t;
|
|
|
| modulus()
|
| {
|
| }
|
|
|
| modulus(modulus%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class equal_to
|
| : public _Binary_fun< ref_equal_to<_Arg_t> >
|
| {
|
| public:
|
| typedef equal_to _Mytype_t;
|
|
|
| equal_to()
|
| {
|
| }
|
|
|
| equal_to(equal_to%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class not_equal_to
|
| : public _Binary_fun< ref_not_equal_to<_Arg_t> >
|
| {
|
| public:
|
| typedef not_equal_to _Mytype_t;
|
|
|
| not_equal_to()
|
| {
|
| }
|
|
|
| not_equal_to(not_equal_to%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class less
|
| : public _Binary_fun< ref_less<_Arg_t> >
|
| {
|
| public:
|
| typedef less _Mytype_t;
|
|
|
| less()
|
| {
|
| }
|
|
|
| less(less%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class greater_equal
|
| : public _Binary_fun< ref_greater_equal<_Arg_t> >
|
| {
|
| public:
|
| typedef greater_equal _Mytype_t;
|
|
|
| greater_equal()
|
| {
|
| }
|
|
|
| greater_equal(greater_equal%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class greater
|
| : public _Binary_fun< ref_greater<_Arg_t> >
|
| {
|
| public:
|
| typedef greater _Mytype_t;
|
|
|
| greater()
|
| {
|
| }
|
|
|
| greater(greater%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class less_equal
|
| : public _Binary_fun< ref_less_equal<_Arg_t> >
|
| {
|
| public:
|
| typedef less_equal _Mytype_t;
|
|
|
| less_equal()
|
| {
|
| }
|
|
|
| less_equal(less_equal%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class logical_and
|
| : public _Binary_fun< ref_logical_and<_Arg_t> >
|
| {
|
| public:
|
| typedef logical_and _Mytype_t;
|
|
|
| logical_and()
|
| {
|
| }
|
|
|
| logical_and(logical_and%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t>
|
| ref class logical_or
|
| : public _Binary_fun< ref_logical_or<_Arg_t> >
|
| {
|
| public:
|
| typedef logical_or _Mytype_t;
|
|
|
| logical_or()
|
| {
|
| }
|
|
|
| logical_or(logical_or%)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t,
|
| typename _Result_t>
|
| ref class ref_unary_negate
|
| {
|
| public:
|
| typedef _Arg_t argument_type;
|
| typedef _Result_t result_type;
|
| typedef _STLCLR UnaryDelegate<argument_type, result_type>
|
| stored_delegate_type;
|
|
|
| ref_unary_negate(stored_delegate_type^ _Function)
|
| : stored_delegate(_Function)
|
| {
|
| }
|
|
|
| bool function(argument_type _Left)
|
| {
|
| return (!stored_delegate(_Left));
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| stored_delegate_type^ stored_delegate;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Fun_t>
|
| ref class unary_negate
|
| {
|
| public:
|
| typedef unary_negate _Mytype_t;
|
| typedef _Fun_t stored_function_type;
|
| typedef typename stored_function_type::argument_type argument_type;
|
| typedef bool result_type;
|
| typedef ref_unary_negate<argument_type,
|
| typename stored_function_type::result_type> ref_type;
|
| typedef _STLCLR UnaryDelegate<argument_type, result_type>
|
| delegate_type;
|
|
|
| explicit unary_negate(stored_function_type% _Func)
|
| : op(_Func)
|
| {
|
| }
|
|
|
| unary_negate(unary_negate%)
|
| {
|
| }
|
|
|
| result_type operator()(argument_type _Left)
|
| {
|
| return (!op(_Left));
|
| }
|
|
|
| operator delegate_type^()
|
| {
|
| return (gcnew delegate_type(gcnew ref_type(op),
|
| %ref_type::function));
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| stored_function_type op;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Fun_t> inline
|
| unary_negate<_Fun_t> not1(_Fun_t% _Func)
|
| {
|
| return (unary_negate<_Fun_t>(_Func));
|
| }
|
|
|
|
|
|
|
|
|
| template<typename _Arg1_t,
|
| typename _Arg2_t,
|
| typename _Result_t>
|
| ref class ref_binary_negate
|
| {
|
| public:
|
| typedef _Arg1_t first_argument_type;
|
| typedef _Arg2_t second_argument_type;
|
| typedef _Result_t result_type;
|
| typedef _STLCLR BinaryDelegate<
|
| first_argument_type, second_argument_type, result_type>
|
| stored_delegate_type;
|
|
|
| ref_binary_negate(stored_delegate_type^ _Function)
|
| : stored_delegate(_Function)
|
| {
|
| }
|
|
|
| bool function(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (!stored_delegate(_Left, _Right));
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| stored_delegate_type^ stored_delegate;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Fun_t>
|
| ref class binary_negate
|
| {
|
| public:
|
| typedef binary_negate _Mytype_t;
|
| typedef _Fun_t stored_function_type;
|
| typedef typename stored_function_type::first_argument_type
|
| first_argument_type;
|
| typedef typename stored_function_type::second_argument_type
|
| second_argument_type;
|
| typedef bool result_type;
|
| typedef ref_binary_negate<first_argument_type, second_argument_type,
|
| typename stored_function_type::result_type> ref_type;
|
| typedef _STLCLR BinaryDelegate<
|
| first_argument_type, second_argument_type, result_type>
|
| delegate_type;
|
|
|
| explicit binary_negate(stored_function_type% _Func)
|
| : op(_Func)
|
| {
|
| }
|
|
|
| binary_negate(binary_negate%)
|
| {
|
| }
|
|
|
| result_type operator()(first_argument_type _Left,
|
| second_argument_type _Right)
|
| {
|
| return (!op(_Left, _Right));
|
| }
|
|
|
| operator delegate_type^()
|
| {
|
| return (gcnew delegate_type(gcnew ref_type(op),
|
| %ref_type::function));
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| stored_function_type op;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Fun_t> inline
|
| binary_negate<_Fun_t> not2(_Fun_t% _Func)
|
| {
|
| return (binary_negate<_Fun_t>(_Func));
|
| }
|
|
|
|
|
|
|
|
|
| template<typename _Arg1_t,
|
| typename _Arg2_t,
|
| typename _Result_t>
|
| ref class ref_binder1st
|
| {
|
| public:
|
| typedef _Arg1_t first_argument_type;
|
| typedef _Arg2_t second_argument_type;
|
| typedef _Result_t result_type;
|
| typedef _STLCLR BinaryDelegate<
|
| first_argument_type, second_argument_type, result_type>
|
| stored_delegate_type;
|
|
|
| ref_binder1st(stored_delegate_type^ _Function, first_argument_type _Left)
|
| : stored_delegate(_Function), value(_Left)
|
| {
|
| }
|
|
|
| result_type function(second_argument_type _Right)
|
| {
|
| return (stored_delegate(value, _Right));
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| stored_delegate_type^ stored_delegate;
|
| first_argument_type value;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Fun_t>
|
| ref class binder1st
|
| {
|
| public:
|
| typedef binder1st _Mytype_t;
|
| typedef _Fun_t stored_function_type;
|
| typedef typename stored_function_type::first_argument_type
|
| first_argument_type;
|
| typedef typename stored_function_type::second_argument_type
|
| second_argument_type;
|
| typedef typename stored_function_type::result_type result_type;
|
| typedef ref_binder1st<first_argument_type, second_argument_type,
|
| result_type> ref_type;
|
| typedef _STLCLR UnaryDelegate<second_argument_type, result_type>
|
| delegate_type;
|
|
|
| binder1st(stored_function_type% _Func,
|
| first_argument_type _Left)
|
| : op(_Func), value(_Left)
|
| {
|
| }
|
|
|
| binder1st(binder1st% _Right)
|
| : op(_Right.op), value(_Right.value)
|
| {
|
| }
|
|
|
| result_type operator()(second_argument_type _Right)
|
| {
|
| return (op(value, _Right));
|
| }
|
|
|
| operator delegate_type^()
|
| {
|
| return (gcnew delegate_type(
|
| gcnew ref_type(op, value),
|
| &ref_type::function));
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| stored_function_type op;
|
| first_argument_type value;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Fun_t,
|
| typename _Arg_t> inline
|
| binder1st<_Fun_t> bind1st(_Fun_t% _Func, _Arg_t _Left)
|
| {
|
| typename _Fun_t::first_argument_type _Val = _Left;
|
|
|
| return (binder1st<_Fun_t>(_Func, _Val));
|
| }
|
|
|
|
|
|
|
|
|
| template<typename _Arg1_t,
|
| typename _Arg2_t,
|
| typename _Result_t>
|
| ref class ref_binder2nd
|
| {
|
| public:
|
| typedef _Arg1_t first_argument_type;
|
| typedef _Arg2_t second_argument_type;
|
| typedef _Result_t result_type;
|
| typedef _STLCLR BinaryDelegate<
|
| first_argument_type, second_argument_type, result_type>
|
| stored_delegate_type;
|
|
|
| ref_binder2nd(stored_delegate_type^ _Function,
|
| second_argument_type _Right)
|
| : stored_delegate(_Function), value(_Right)
|
| {
|
| }
|
|
|
| result_type function(first_argument_type _Left)
|
| {
|
| return (stored_delegate(_Left, value));
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| stored_delegate_type^ stored_delegate;
|
| second_argument_type value;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Fun_t>
|
| ref class binder2nd
|
| {
|
| public:
|
| typedef binder2nd _Mytype_t;
|
| typedef _Fun_t stored_function_type;
|
| typedef typename stored_function_type::first_argument_type
|
| first_argument_type;
|
| typedef typename stored_function_type::second_argument_type
|
| second_argument_type;
|
| typedef typename stored_function_type::result_type result_type;
|
| typedef ref_binder2nd<first_argument_type, second_argument_type,
|
| result_type> ref_type;
|
| typedef _STLCLR UnaryDelegate<first_argument_type, result_type>
|
| delegate_type;
|
|
|
| binder2nd(stored_function_type% _Func,
|
| second_argument_type _Right)
|
| : op(_Func), value(_Right)
|
| {
|
| }
|
|
|
| binder2nd(binder2nd% _Right)
|
| : op(_Right.op), value(_Right.value)
|
| {
|
| }
|
|
|
| result_type operator()(second_argument_type _Left)
|
| {
|
| return (op(_Left, value));
|
| }
|
|
|
| operator delegate_type^()
|
| {
|
| return (gcnew delegate_type(
|
| gcnew ref_type(op, value),
|
| &ref_type::function));
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| stored_function_type op;
|
| second_argument_type value;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Fun_t,
|
| typename _Arg_t> inline
|
| binder2nd<_Fun_t> bind2nd(_Fun_t% _Func, _Arg_t _Right)
|
| {
|
| typename _Fun_t::second_argument_type _Val = _Right;
|
|
|
| return (binder2nd<_Fun_t>(_Func, _Val));
|
| }
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t,
|
| typename _Mycomp_t>
|
| ref class comparer_less
|
| {
|
| public:
|
| typedef comparer_less<_Arg_t, _Mycomp_t> _Mytype_t;
|
| typedef _Arg_t argument_type;
|
| typedef _STLCLR BinaryDelegate<
|
| argument_type, argument_type, bool>
|
| delegate_type;
|
|
|
| comparer_less(_Mycomp_t^ _Comp)
|
| : _Mycomp(_Comp)
|
| {
|
| }
|
|
|
| comparer_less(comparer_less% _Right)
|
| : _Mycomp(_Right._Mycomp)
|
| {
|
| }
|
|
|
| bool operator()(argument_type _Left, argument_type _Right)
|
| {
|
| return (function(_Left, _Right));
|
| }
|
|
|
| operator delegate_type^()
|
| {
|
| return (gcnew delegate_type(%function));
|
| }
|
|
|
| static bool function(argument_type _Left, argument_type _Right)
|
| {
|
| return (_Mycomp->Compare(_Left, _Right) < 0);
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| _Mycomp_t^ _Mycomp;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Arg_t> inline
|
| comparer_less<_Arg_t,
|
| System::Collections::Generic::IComparer<_Arg_t> >^
|
| make_comparer_less(
|
| System::Collections::Generic::IComparer<_Arg_t>^ _Comp)
|
| {
|
| typedef System::Collections::Generic::IComparer<_Arg_t> _Mycomp_t;
|
|
|
| return (gcnew comparer_less<_Arg_t, _Mycomp_t>(_Comp));
|
| }
|
|
|
| inline comparer_less<System::Object^, System::Collections::IComparer>^
|
| make_comparer_less(System::Collections::IComparer^ _Comp)
|
| {
|
| typedef System::Collections::IComparer _Mycomp_t;
|
|
|
| return (gcnew comparer_less<System::Object^, _Mycomp_t>(_Comp));
|
| }
|
| }
|
| #endif
|
|
|