Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interpreting C++20 standard description of ITER_TRAITS

Can someone explain me what this line in iterator.concepts.general#1 means from the C++ standard draft:

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>.

like image 269
ayub.ab Avatar asked Dec 01 '21 22:12

ayub.ab


1 Answers

The primary iterator_traits<I> template will fill in members like value_type and reference from corresponding members of I. If your iterator type does not have those members (for example, all pointer types), you can specialize std::iterator_traits<your_iterator_type> to provide those members instead, and provide them in the traits class.

The ITER_TRAITS(I) conceptual metafunction represents this. If there is no specialization of iterator_traits for the iterator type I, then it gets the members from I itself. If it is specialized, then it gets them from iterator_traits<I>.

like image 163
Nicol Bolas Avatar answered Oct 16 '22 23:10

Nicol Bolas