无法访问指针向量映射元素,
到我的私人部分我有:
vector< vector<map<unsigned short int,col_data> > *> buffer_vectorS;
vector< map<unsigned short int,col_data> > * buffer_current;
map<unsigned short int,col_data> buffer_current_map;
(coldata是一个简单的结构:int,int,int,double)
稍后我创建了一个地图数据向量,并保存其指针
vector<map<unsigned short int,col_data> > * buffer_vector = new vector<map<unsigned short int,col_data> >;
buffer_vectorS.push_back(buffer_vector);
buffer_current = buffer_vector;
稍后我想使用buffer_current的地图元素来获取-存储数据,
buffer_current_map = &buffer_current[index];
但这最后一个无法编译...我不知道如何写它... 如何访问 buffer_current 的一项? 你能帮助我吗 ?
into my private section I have :
vector< vector<map<unsigned short int,col_data> > *> buffer_vectorS;
vector< map<unsigned short int,col_data> > * buffer_current;
map<unsigned short int,col_data> buffer_current_map;
( coldata is a simple structure: int, int, int, double )
Later I create a vector of map data, and save its pointer
vector<map<unsigned short int,col_data> > * buffer_vector = new vector<map<unsigned short int,col_data> >;
buffer_vectorS.push_back(buffer_vector);
buffer_current = buffer_vector;
Later I'd want to use the map element of the buffer_current to get-store data,
buffer_current_map = &buffer_current[index];
But this last does not compile.... I dont know how to write it...
How can I access to an item of buffer_current?
Can you help me ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的意思是:
不过请注意,这将在地图上执行复制操作。您可能希望使用指针语义访问映射:
那么将不会进行任何复制。不过,如果对向量进行大小调整,则指针可能会无效。
Do you mean:
Be warned though, that will perform a copy operation on the map. You might want to access the map using pointer semantics:
Then no copy will be done. Although, the pointer might be invalidated if a resize is done on the vector.