1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
template<class f, class h, class g>
struct myfun : public unary_function<typename g::argument_type, typename f::result_type> {
myfun(f &o1, h &o2, g &o3) : op1( o1 ), op2( o2 ), op3( o3 )
{ }
result_type operator ()(const typename argument_type &x) const
{
return op1(op2( x ), op3( x ));
}
private:
f op1;
h op2;
g op3;
};
template<class T>
struct my : unary_function<typename T::argument_type, bool> {
my(const T &o) : op( op )
{ }
bool operator ()(const typename T::argument_type &arg) const
{
return ( !op( arg ) );
}
private:
T op;
};
void main()
{
myfun<logical_and<int>, binder1st<less<int> >, binder2nd<less<int> > > m(logical_and<int>(), bind1st(less<int>(), 3), bind2nd(less<int>(), 8));
my<myfun<logical_and<int>, binder1st<less<int> >, binder2nd<less<int> > > > x( m );
for (int i = 0; i < 10; i++)
cout << x( i ) << " "; // its wrong but why ?!!! Very interesting for me because all of value is 1 !!!
// you can test m( i ) instead of x( i ) and see ....
cin.get();
}
|