
2006/1/15, Felipe Magno de Almeida <felipe.m.almeida@gmail.com>:
[snip]
Offtopic: Maybe the problem doesnt lie on const/non-const member functions? And the ugly syntax to choose the const when using a non-const class? Maybe this proposal shouldnt be more general? Not applying only to iterator/const_iterator. IMO, if it was, it would probably have more chance of acceptance.
IMHO, cbegin/cend proposal may be too specific as you mentioned. There may be other cases where const/non-const member function overload resolution by programmers is desirable. And inline cv-qualification conversion may become a more generic approach in such cases. For example, consider the following code. // a vector class with copy-on-write template< class T > class vector_with_cow { ..... T &operator[]( size_type index ); T const &operator[]( size_type index ) const; ..... }; void f( vector_with_cow< int > &v ) { if( const_( v )[0] == 0 ){ // do not require deep copy return; } // write some values into v, require deep copy } Best regards, -- Ai Azuma <ai.azuma@gmail.com>