Typedef for iterators denoting positions to insert/erase

Jonathan Wakely jwakely@redhat.com
Fri Aug 29 14:16:00 GMT 2014

In the new std::string implementation I'm using the following typedef:

#if __cplusplus < 201103L
      typedef iterator __pos_iterator;
      typedef const_iterator __pos_iterator;

This can then be used to avoid littering the rest of the file with preprocessor
conditionals like:

#if __cplusplus >= 201103L
      erase(const_iterator __first, const_iterator __last) noexcept
      erase(iterator __first, iterator __last)

Is this worth doing in the other containers too?

I'm undecided whether it's clearer to read the preprocessor condition
or a declaration with the non-standard __pos_iterator type, but I
think I'd prefer to use the new type. Any other opinions?

More information about the Libstdc++ mailing list