// functortest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
template<typename T1, typename T2>
class unary_function
{
public:
typedef T1 first_argument_type;
typedef T2 result_type;
};
template<typename T>
struct unary_predicate : public unary_function<T, bool>
{
};
struct greater : public unary_predicate<int>
{
int _val;
greater(int val) :_val(val){}
inline bool operator()(int val)
{
return val > _val;
}
};
template<typename T, typename Comp>
bool test(T val, Comp comp)
{
//Comp::result_type ret;
//ret = comp(val);
return comp(val);
}
bool _greater(int val)
{
return val > 10;
}
int main(int argc, char* argv[])
{
std::cout << "test(5, greater(10)) return: " << test(5, greater(10)) << std::endl;
std::cout << "test(11, greater(10)) return: " << test(11, greater(10)) << std::endl;
std::cout << "test(5, _greater) return: " << test(5, _greater) << std::endl;
std::cout << "test(11, _greater) return: " << test(11, _greater) << std::endl;
std::cout << "test(5, greater(1)) return: " << test(5, greater(1)) << std::endl;
getch();
return 0;
}