[英]Non standard syntax error in iterator? (C++)
void PointCloud::Create(std::vector<std::vector<cv::Point3d>> threeDPointSpace){
std::vector<std::vector<cv::Point3d>>::iterator row;
std::vector<cv::Point3d>::iterator col;
for (row = threeDPointSpace.begin(); row != threeDPointSpace.end(); row++) {
for (col = row->begin(); col != row->end(); col++) {
cv::Point3d thisOne = col._Getcont; // error reported here
vertices.push_back(VertexFormat(glm::vec3(thisOne.x, thisOne.y, thisOne.z), glm::vec4(1.0, 0.0, 1.0, 1.0)));
totalData++;
}
}
}
Error message reads: 错误消息显示为:
Severity Code Description Project File Line Error C3867 'std::_Iterator_base12::_Getcont': non-standard syntax;
严重性代码说明项目文件行错误C3867'std :: _ Iterator_base12 :: _ Getcont':非标准语法; use '&' to create a pointer to member
使用“&”创建指向成员的指针
What does this mean? 这是什么意思? How can I fix this?
我怎样才能解决这个问题? Am I not using this iterator schema correctly?
我没有正确使用此迭代器架构吗? I'm attempting to access these elements.
我正在尝试访问这些元素。
You're trying to use the function std::vector<cv::Point3d>::iterator::_Getcont
without calling it ( ()
) or using address-of syntax ( &
), which is indeed non-standard. 您正在尝试使用函数
std::vector<cv::Point3d>::iterator::_Getcont
而不调用它( ()
)或使用地址语法( &
),这实际上是非标准的。
cv::Point3d thisOne = col._Getcont();
However, this function is from the internals of Visual Studio's standard library implementation (the leading _
and the lack of a mention in cppreference.com's documentation of the public interface for RandomAccessIterator s being the main clues); 但是,此功能来自Visual Studio标准库实现的内部(主要
_
并且cppreference.com文档中未提及RandomAccessIterator的公共接口是主要线索); I have no idea why you're trying to use it. 我不知道您为什么要尝试使用它。 Just dereference the iterator, like everyone else:
像其他所有人一样,只需取消引用迭代器即可:
const cv::Point3d& thisOne = *col;
Since col
is a std::vector<cv::Point3d>::iterator
you would have to access an attribute from the Point3d
using 由于
col
是std::vector<cv::Point3d>::iterator
您必须使用以下方法从Point3d
访问属性
cv::Point3d thisOne = col->_Getcont;
and if this is a method, make sure you actually call the method 如果这是一个方法,请确保您实际调用了该方法
cv::Point3d thisOne = col->_Getcont();
Should not you use? 你不应该使用吗?
cv::Point3d thisOne = col->_Getcont;
Or if _Getcont is a member function 或_Getcont是成员函数
cv::Point3d thisOne = col->_Getcont();
Or 要么
cv::Point3d thisOne = ( *col )._Getcont;
cv::Point3d thisOne = ( *col )._Getcont();
Or maybe you could write simply 也许你可以简单地写
cv::Point3d thisOne = *col;
because the type of the left object is the same as the type of expression *col
. 因为左对象的类型与表达式
*col
的类型相同。
In this case the function could be written like 在这种情况下,函数可以像
void PointCloud::Create(std::vector<std::vector<cv::Point3d>> threeDPointSpace)
{
for ( auto &row : threeDPointSpace )
{
for ( auto &thisOne : row )
{
vertices.push_back(VertexFormat(glm::vec3(thisOne.x, thisOne.y, thisOne.z), glm::vec4(1.0, 0.0, 1.0, 1.0)));
totalData++;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.