我有一个std::map,我想在第二个条目开始迭代.
我可以解决这个问题,但我很困惑为什么"明显的"语法不能编译.错误消息没有帮助,因为它引用std::string,我在这里没有使用.
这是一些代码
// Suppose I have some map ...
std::map<int, int> pSomeMap;
// This is fine ...
std::map<int, int>::const_iterator pIterOne = pSomeMap.begin();
++pIterOne;
// This doesn't compile ...
std::map<int, int>::const_iterator pIterTwo = pSomeMap.begin() + 1;
Run Code Online (Sandbox Code Playgroud)
VS2012在上面的行中给出以下错误
错误C2784:'std :: _ String_iterator <_Mystr> std :: operator +(_ String_iterator <_Mystr> :: difference_type,std :: _ String_iterator <_Mystr>)':无法推断'std :: _ String_iterator <_Mystr>'的模板参数来自'int'
谁能解释一下这里发生了什么?