#ifndef UTILITY_FUNCTIONAL_CUSTOM_H #define UTILITY_FUNCTIONAL_CUSTOM_H #pragma once #include #pragma warning(push) #pragma warning(disable : 4510 4610) // stlport custom code template struct __unary_fun_aux : private _Operation { typedef typename _Operation::argument_type argument_type; typedef typename _Operation::result_type result_type; }; # define __UNARY_ARG(__Operation,__type) __unary_fun_aux<__Operation>::__type template class unary_compose : public std::unary_function { protected: _Operation1 _M_fn1; _Operation2 _M_fn2; public: unary_compose(const _Operation1& __x, const _Operation2& __y) : _M_fn1(__x), _M_fn2(__y) {} typename _Operation1::result_type operator()(const typename _Operation2::argument_type& __x) const { return _M_fn1(_M_fn2(__x)); } //// const ÁÖ¼® ó¸® //// operator³»ºÎ¿¡¼­ ¸É¹ö¸¦ ¼öÁ¤ÇÒ ¼ö ¾ø¾î¼­ //typename _Operation1::result_type //operator()(typename _Operation2::argument_type& __x) /*const*/ { // return _M_fn1(_M_fn2(__x)); //} }; // com(g,f) -> g(f(x)) template inline unary_compose<_Operation1,_Operation2> compose1(const _Operation1& __fn1, const _Operation2& __fn2) { return unary_compose<_Operation1,_Operation2>(__fn1, __fn2); } template struct _Select1st : public std::unary_function<_Pair, typename _Pair::first_type> { const typename _Pair::first_type& operator()(const _Pair& __x) const { return __x.first; } }; template struct _Select2nd : public std::unary_function<_Pair, typename _Pair::second_type> { const typename _Pair::second_type& operator()(const _Pair& __x) const { return __x.second; } }; template struct select1st : public _Select1st<_Pair> {}; template struct select2nd : public _Select2nd<_Pair> {}; //example /*std::for_each( m_pZoneHash->begin(), end = m_pZoneHash->end(), compose1( mem_fun(&GameZone::Release), select2nd() ));*/ #pragma warning(pop) #endif //UTILITY_FUNCTIONAL_CUSTOM_H