I've read this from Cppreference
I'm confusing about what is the difference between:
std::iterator_traits<it>::value_type *- and
std::iterator_traits<it>::pointer.
I did dive in the text and try to figure out the difference, but the more I read the more I get confusing.
Something tells me they would be the same, but logically they seem not.
So what is the actual difference between them, I would like an example if possible.
value_typeis supposed to have cv-qualifiers (constand/orvolatile) removed from it, so you could have e.g.:Also, for the quirky iterators that compute the result of dereferencing on the fly (such as
std::vector<bool>::iterator),reference(the return type ofoperator*) andpointer(the return type ofoperator->) can be proxy classes that merely pretend to be pointers/references.The exact requirements on those proxy classes appear to be underspecified, but at least
referenceis expected to be convertible tovalue_type, andpointeris expected to overload->and work withstd::to_address.