identity (证同性函数)
f(x)=x
template<class T>
struct identity : public unary_function<T, T>
{
const T& operator()(const T& x) const
{
return x;
}
}
identity 的数学含义是证同性函数,即不做修改,保持原值;
std::identity<int>()(5);
// 第一对括号表示仿函数的实例化,因为其构造函数为空的默认构造
// 第二对括号表示调用括号运算符重载