用常量迭代器从STL容器中擦除 [英] Erasing from an STL container by a constant iterator

查看:133
本文介绍了用常量迭代器从STL容器中擦除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 C ++参考,STL容器在C ++中被修复11标准在擦除方法中采用常量迭代器。下面的代码不会在g ++ 4.7中编译,并且 c ++ 0x 已启用。

According the the C++ reference STL containers were fixed in C++11 standard to take constant iterator in the erase methods. The following code would not compile in g++4.7 with c++0x enabled.

#include <vector>

int main()
{
    std::vector<int> vector;
    vector.push_back(0);

    std::vector<int>::const_iterator vectorItr = vector.begin();
    vector.erase(vectorItr);
}

很明显,新的签名没有实现。有什么信息可以解决这个问题吗?我无法在 GCC中的C ++ 0x / C ++ 11支持中找到任何相关信息 article。

Obviously the new signatures were not implemented. Is there any information when this issue will be fixed? I could not find any respective information in the C++0x/C++11 Support in GCC article.

推荐答案

HERE

In HERE:


< 部分: 23.3.6 em>状态 部分

评论:插入和擦除成员不包含const_iterator参数(N2350)。

Section: 23.3.6
Description: Class template vector
Status: Partial
Comments: insert and erase members do not take const_iterator arguments (N2350).

这篇关于用常量迭代器从STL容器中擦除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆