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


int main ( void ) {

    using namespace std;

    for ( const vector< bool > v :
        std::initializer_list< vector< bool > >{
        { true, true, true }, { false }, { true, false }, { } } )
    {

        const auto
            vb = v.cbegin(),
            ve = v.cend();

        cout << "===" << endl;

        // Needlessly complicated by having to invert the logic ...
        cout << "All are false: " << boolalpha
           << all_of( vb, ve, logical_not< bool >() )
           << endl;

        // ... for both, true and false.
        cout << "All are true: " << boolalpha
            << none_of( vb, ve, logical_not< bool >() )
            << endl;


        // Unappealing because of trivial explicit lambda.

        const auto id = [] ( const bool b ) { return b; };

        cout << "All are false: " << boolalpha
            << none_of ( vb, ve, id )
            << endl;

        cout << "All are true: " << boolalpha
            << all_of ( vb, ve, id )
            << endl;


        // Unnecessary explicit formulation of the iteration:

        cout << "All are false: " << boolalpha
            << !accumulate ( vb, ve, false, logical_or< bool >() )
            << endl;

        cout << "All are true: " << boolalpha
            << accumulate ( vb, ve, true, logical_and< bool >() )
            << endl;
        }

    return 0;
}

