Title
Concept maps and the range-based for
Status
concepts
Section
8.6.5 [stmt.ranged]
Submitter
James Widman

Created on 2009-04-08.00:00:00 last changed 186 months ago

Messages

Date: 2009-04-08.00:00:00

The expansion of the range-based for statement is given in 8.6.5 [stmt.ranged] paragraph 1 as:

    {
      auto && __range = ( expression );
      for ( auto __begin = std::Range<_RangeT>::begin(__range),
                 __end = std::Range<_RangeT>::end(__range);
            __begin != __end;
            ++__begin ) {
        for-range-declaration = *__begin;
        statement
      }
    }

In a non-templated context, the concept map to std::Range has been dropped, so the operators and initialization will be whatever they would normally be; if the concept map replaced those with some customized version (e.g., if the iterator's ++ were supposed to skip odd-numbered elements), that customized meaning would be lost.

What we really want are the operators associated with the concept map to std::Iterator that was used to satisfy the associated requirement (std::Iterator<iterator>) within std::Range<_RangeT> (in whatever concept map was used to satisfy std::Range<_RangeT>). That is, if the grammar permitted it, we want something like

    std::Range<_RangeT>::concept_map
      ::std::Iterator<std::Range<_RangeT>::iterator>::operator++(_begin)

Another alternative would be, if issue 856 is resolved by injecting the declaration of associated functions into concept definitions, something like

    std::Range<_RangeT>::operator++(__begin)
History
Date User Action Args
2009-08-03 00:00:00adminsetstatus: open -> concepts
2009-04-08 00:00:00admincreate