Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

23 Iterators library [iterators]

23.3 Iterator requirements [iterator.requirements]

23.3.4 Iterator concepts [iterator.concepts]

23.3.4.1 General [iterator.concepts.general]

For a type I, let ITER_­TRAITS(I) denote the type I if iterator_­traits<I> names a specialization generated from the primary template.
Otherwise, ITER_­TRAITS(I) denotes iterator_­traits<I>.
  • If the qualified-id ITER_­TRAITS(I)​::​iterator_­concept is valid and names a type, then ITER_­CONCEPT(I) denotes that type.
  • Otherwise, if the qualified-id ITER_­TRAITS(I)​::​iterator_­category is valid and names a type, then ITER_­CONCEPT(I) denotes that type.
  • Otherwise, if iterator_­traits<I> names a specialization generated from the primary template, then ITER_­CONCEPT(I) denotes random_­access_­iterator_­tag.
  • Otherwise, ITER_­CONCEPT(I) does not denote a type.
Note
:
ITER_­TRAITS enables independent syntactic determination of an iterator's category and concept.
— end note
 ]
Example
:
struct I {
  using value_type = int;
  using difference_type = int;

  int operator*() const;
  I& operator++();
  I operator++(int);
  I& operator--();
  I operator--(int);

  bool operator==(I) const;
  bool operator!=(I) const;
};
iterator_­traits<I>​::​iterator_­category denotes input_­iterator_­tag, and ITER_­CONCEPT(I) denotes random_­access_­iterator_­tag.
— end example
 ]