Does a C++11 range-based for loop condition get evaluated every cycle?

Solution 1:

It is only evaluated once. The standard defines a range-based for statement as equivalent to:

{
    auto && __range = range-init;
    for ( auto __begin = begin-expr, __end = end-expr; __begin != __end; ++__begin ) {
        for-range-declaration = *__begin;
        statement
    }
}

where range-init is the expression (surrounded by parentheses) or braced-init-list after the :