What is the use of a nested pointer type in iterator_traits?

Class template std::iterator_traitsdefines the 5 sub-types: iterator_category, value_type, difference_type, pointerand reference. When viewing the header sources of <algorithm>both libC ++ and libstdC ++, you can see many uses value_type, difference_typeand iterator_category, but only one for reference(inside std::iter_swap) and none for pointer.

My application uses the reference proxy iterator reference of the proxy server. I want to move on to using Boost iterator_facade, which allows me to configure the link type from the default T&to an arbitrary type, but not so for the pointer type, which is T*the default. I want to avoid being bitten by some deeply hidden use of a nested type pointer.

Note : the iterator is a proxy for the built-in type without nested elements, so I do not need compatibility with operator->(for which the return type will be pointer).

Question : what use cases exist in the standard library for a nested type pointerinside iterator_traits?

+3
source share
1

iterator_category, value_type difference_type ( ), pointer reference iterator_traits, -, , .

24.2.1 [iterator.requirements.general]

1 [..] i, (*i).m , i->m , (*i).m. [...]

24.4.1. [iterator.traits]

[...] ,

 iterator_traits<Iterator>::reference
 iterator_traits<Iterator>::pointer 

, - a, , *a a->, . [...]

T* T& pointer reference, , . , Boost.Iterator

reference ( ) , value_type. , value_type , - operator->. , , reference -, operator->.

iterator_facade operator-> operator[] . , iterator_facade.

: - value_type .m ->m, pointer iterator_traits, -, boost::iterator_facade .

+1

All Articles