简体   繁体   English

std::reverse_iterator 成员函数之间的区别:_Get_current() 和 base()?

[英]Difference between std::reverse_iterator member functions: _Get_current() and base()?

Both member functions appear to do the same thing.两个成员函数似乎都在做同样的事情。
In the example below, both return an iterator pointing to the same memory location.在下面的示例中,两者都返回一个指向同一 memory 位置的迭代器。

a) Is there any practical difference? a) 有什么实际区别吗?

b) Why cant I find any info for _Get_current() in the std class documentation? b) 为什么我在标准 class 文档中找不到_Get_current()的任何信息? 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();

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.如果您看到以_后跟大写字母开头的标识符,则该标识符正被 C++ 实现的内部使用,您永远不应使用该标识符。 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.只需使用实际界面即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM