哪位高手知道less函数的源代码
谁知道less函数的源代码?
我尝试写了一下,不行,
------解决方案--------------------
_Fn2::first_argument_type
_Fn2::second_argument_type
_Fn2::result_type
这些不都是么
我尝试写了一下,不行,
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
template <class T>
struct F : binary_function <T,T,bool>
{
bool operator() ( T x, T y) {return x<y;}
};
int main(int argc,char* argv[])
{
bind1st(F<int>(),1)(2) ;
bind2nd(F<int>(),1)(2) ;
getchar();
return 0;
}
------解决方案--------------------
template<class _Fn2>
class binder1st
: public unary_function<typename _Fn2::second_argument_type,
typename _Fn2::result_type>
{ // functor adapter _Func(stored, right)
public:
typedef unary_function<typename _Fn2::second_argument_type,
typename _Fn2::result_type> _Base;
typedef typename _Base::argument_type argument_type;
typedef typename _Base::result_type result_type;
binder1st(const _Fn2& _Func,
const typename _Fn2::first_argument_type& _Left)
: op(_Func), value(_Left)
{ // construct from functor and left operand
}
result_type operator()(const argument_type& _Right) const
{ // apply functor to operands
return (op(value, _Right));
}
result_type operator()(argument_type& _Right) const
{ // apply functor to operands
return (op(value, _Right));
}
protected:
_Fn2 op; // the functor to apply
typename _Fn2::first_argument_type value; // the left operand
};
_Fn2::first_argument_type
_Fn2::second_argument_type
_Fn2::result_type
这些不都是么