#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

// unary functor; performs '&&'
template <typename T>
struct AND
{
    function<bool (const T&)> x;
    function<bool (const T&)> y;

    AND(function<bool (const T&)> xx, function<bool (const T&)> yy) 
             : x(xx), y(yy) {}
    bool operator() ( const T &arg ) { return x(arg) && y(arg); }
};

// helper
template <typename T>
AND<T> And(function<bool (const T&)> xx, function<bool (const T&)> yy)
{
    return AND<T>(xx,yy);
}

bool is_odd(int n) { return n%2; }
bool is_big(int n) { return n>5; }


bool big_odd_exists( vector<int>::iterator first, vector<int>::iterator last ) 
{
	/*
    function<bool (const int &)> fun1 = is_odd;
    function<bool (const int &)> fun2 = is_big;
    */

    //return any_of( first, last, And( fun1, fun2 ) );  // instantiating an And object
    return any_of( first, last, And<int>( is_odd, is_big ) );
}

int main()
{
    std::vector<int> n = {1, 3, 5, 7, 9, 10, 11};

    cout << "exists : " << big_odd_exists( n.begin(), n.end() ) << endl;
}
