C++ Function Objects in TR1
By Pete Becker, May 01, 2005
The Technical Report on C++ Library Extensions (TR1) introduces four new function object templates that use more sophisticated implementation techniques than the function object templates in the C++ Standard Library.
May, 2005: C++Function Objects in TR1
Listing 6
#include <functional>
#include <iostream>
#include <math.h>
using std::cout;
using std::tr1::function;
int main()
{
function<double(double)> func = cosl;
cout << "cos(0.0): " << func(0.0) << '\n';
func = sinf;
cout << "sin(0.0): " << func(0.0) << '\n';
return 0;
}