/* ========================================================================== * ÀÛ ¼º ÀÚ : À̼ø±Ô * ÀÛ ¼º ÀÏ : 2006.12.04 * ³» ¿ë : ¹ü¿ë ÇÔ¼öÀÚ ÅÛÇø´ ¸ðÀ½ * ÁÖÀÇ»çÇ× : *===========================================================================*/ #pragma once #include "CharTraits.h" /// ¸â¹ö ÇÔ¼öÀÚ template class tMemberFunction { typedef RESULT (T::*Func)( void ); public: explicit tMemberFunction( Func func ) : mFunc( func ) { } RESULT operator () ( T* p ) const { return (p->*mFunc)(); } private: /// ÇÔ¼ö Æ÷ÀÎÅÍ Func mFunc; }; template inline tMemberFunction MemFunc(RESULT (T::*f)()) { return tMemberFunction(f); } template class tMemberFunctionRef { typedef RESULT (T::*Func)( void ); public: explicit tMemberFunctionRef( Func func ) : mFunc( func ) { } RESULT operator () ( T& r ) const { return (r.*mFunc)(); } private: /// ÇÔ¼ö ·¹ÆÛ·±½º Func mFunc; }; template inline tMemberFunctionRef MemFuncRef(RESULT (T::*f)()) { return tMemberFunctionRef( f ); } /// ´ÜÇ× ºñ±³ ÇÔ¼öÀÚ template class tUnaryEqual { public: T mVal; tUnaryEqual( const T& x ) : mVal( x ) { } bool operator () ( const T& x ) const { return x == mVal; } }; template<> class tUnaryEqual { public: char* mVal; bool operator () ( const char* x ) const { return tCharTraits::Compare( mVal, x ) == 0; } }; template<> class tUnaryEqual { public: const char* mVal; bool operator () ( const char* x ) const { return tCharTraits::Compare( mVal, x ) == 0; } }; /// ºñ±³ ÇÔ¼öÀÚ template class tBinaryEqual { public: bool operator () ( const T& x, const T& y ) const { return x == y; } }; template<> class tBinaryEqual { public: bool operator () ( const char* x, const char* y ) const { return tCharTraits::Compare( x, y ) == 0; } }; template<> class tBinaryEqual { public: bool operator () ( const char* x, const char* y ) const { return tCharTraits::Compare( x, y ) == 0; } }; template class tBinaryGreater { public: bool operator () ( const T& x, const T& y ) const { return x > y; } }; template<> class tBinaryGreater { public: bool operator () ( const char* x, const char* y ) const { return tCharTraits::Compare( x, y ) > 0; } }; template<> class tBinaryGreater { public: bool operator () ( const char* x, const char* y ) const { return tCharTraits::Compare( x, y ) > 0; } }; template class tBinaryLess { public: bool operator () ( const T& x, const T& y ) const { return x < y; } }; template<> class tBinaryLess { public: bool operator () ( const char* x, const char* y ) const { return tCharTraits::Compare( x, y ) < 0; } }; template<> class tBinaryLess { public: bool operator () ( const char* x, const char* y ) const { return tCharTraits::Compare( x, y ) < 0; } }; /// ¼±Åà ÇÔ¼öÀÚ template class tSelect1st { public: const typename Pair::FIRST& operator () ( const Pair& x ) const { return x.mFirst; } }; template class tSelect2nd { public: const typename Pair::SECOND& operator () ( const Pair& x ) const { return x.mSecond; } }; template class tIdentity { public: const T& operator () ( const T& x ) const { return x; } };