#include <iostream>
#include <algorithm>
#include <functional>
 
bool PlanA() { return true; }
bool PlanB() { return true; }
bool PlanC() { return false; }
bool Error() { return true; }
 
int main() {
    
    using namespace std;
    
    function<bool()> steps[] = { PlanA, PlanB, PlanC, Error, 
                                 [](){ return false; } /* sentinal */ };
    auto failed_at = begin(steps);
    while( (*failed_at++)() )
        ;
        
    cout << "failed at: " << distance( begin(steps), failed_at ) << endl;
}