Home > front end >  Difference between std::reverse_iterator member functions: _Get_current() and base()?
Difference between std::reverse_iterator member functions: _Get_current() and base()?

Time:09-28

Both member functions appear to do the same thing.
In the example below, both return an iterator pointing to the same memory location.

a) Is there any practical difference?

b) Why cant I find any info for _Get_current() in the std class documentation? I suspect the underscore prefix is a clue.

std::string s = std::string( "A B C" ) ;    

std::string::iterator iter1 = s.begin();
std::string::reverse_iterator iter2 = s.rbegin();

std::string::iterator iter3 = iter2.base();
std::string::iterator iter4 = iter2._Get_current();

CodePudding user response:

If you ever see an identifier that starts with an _ followed by a capital letter, that identifier is being used by the internals of the C implementation and should never be used by you. You don't see it documented because it's for internal use only, specific to that implementation of the library type.

Just use the actual interface.

  • Related