Skip to content
  • Murray Cumming's avatar
    C++11: range-based for loops: Don't get the container separately. · 12453ef5
    Murray Cumming authored
    Don't use an intermediate variable to get the container.
    Range-based for loops only evaluate the second part once so this is
    fine. This simplifies code by not making us think about whether the
    variable is used later in the method.
    
    This is only useful with containers that don't need to be
    const-iterated. We can const_cast<> the container, but that is
    lengthy and involves mentining the type.
    12453ef5