> Why doesn't the second overload return const_pointer?
std::list<T,A>::iterator::pointer is T*
std::list<T,A>::const_iterator::pointer is const T*
pointer operator->() const in the iterator class returns the pointer defined by the iterator.
The name is the same in both classes, but the types are different.
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include <list>
#include <typeinfo>
void foo( int* ) { std::cout << "pointer to int\n" ; }
void foo( constint* ) { std::cout << "pointer to const int\n" ; }
int main()
{
foo( std::list<int>::iterator::pointer{} ) ; // pointer to int
foo( std::list<int>::const_iterator::pointer{} ) ; // pointer to const int
}