Listing 2: A typical implementation of bind2nd and binder2nd
template<class BinFunc> class binder2nd : public unary_function< BinFunc::first_argument_type, BinFunc::result_type > { public: binder2nd( const BinFunc& func, const BinFunc::second_argument_type& secondArg ) : m_func(func), m_secondArg(secondArg) {} result_type operator()(const argument_type& first) const { return m_func(first, m_secondArg); } protected: BinFunc m_func; BinFunc::second_argument_type m_secondArg; }; template<class BinFunc, class SecondArg> inline binder2nd<BinFunc> bind2nd( const BinFunc& func, const SecondArg& secondArg ) { return binder2nd<BinFunc>( func, BinFunc::second_argument_type(secondArg) ); } End of Listing