无法在Mac上访问std vector iterator _Ptr [英] Can't access std vector iterator _Ptr on Mac
问题描述
在Visual Studio上,这段代码就像一个魅力:
On Visual Studio this snippet of code works like a charm:
auto child = node.childs.begin();
while (child != node.childs.end()) {
vector<int> siblings;
for (auto it : node.childs){
if (it != *child._Ptr)siblings.push_back( it );
}
if (CheckSomething( tree, *child._Ptr, siblings ) > 0) {
//delete that child
child = node.childs.erase( child );
}
else ++child;
}
但是在XCode上使用相同的代码我遇到了_Ptr不存在的错误?是不是具有相同结构的std库?为什么会这样?
but with the same code on XCode I got errors like _Ptr is non existent? is not the same std library with the same structures? why this happen?
File.cpp:1745:22: No member named '_Ptr' in 'std::__1::__wrap_iter<int *>'
提前致谢
推荐答案
规范没有定义这样的成员变量。 _Ptr
是特定于实现的(在本例中为MSVC特定的)成员变量,在其他实现中可能存在也可能不存在。
The specification defines no such member variable. _Ptr
is an implementation-specific (in this case MSVC-specific) member variable that may or may not exist on other implementations.
通常,以下划线开头的名称是指特定于实现的成员。如果您希望代码可移植或不在编译器版本之间中断,请不要访问它们。
Generally names starting with underscores refer to implementation-specific members. Don't ever access those, if you want your code to be portable or not to break between compiler versions.
这篇关于无法在Mac上访问std vector iterator _Ptr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!