【发布时间】:2015-06-28 03:28:08
【问题描述】:
这是我的代码:
#include <set>
#include <iostream>
using namespace std;
int main(){
set<int> st;
st.insert(1);
int x = st.find(1) - st.begin();
return 0;
}
我收到error: no match for 'operator-' in 'st.std::set<_Key, _Compare, _Alloc>::find [with _Key = int, _Compare = std::less<int>, _Alloc = std::allocator<int>](((const int&)((const int*)(&1)))) - st.std::set<_Key, _Compare, _Alloc>::begin [with _Key = int, _Compare = std::less<int>, _Alloc = std::allocator<int>]()'。
我无法弄清楚迭代器差异是如何突然停止工作的!我在这里遗漏了什么吗?
【问题讨论】:
标签: c++ c++11 iterator c++14 const-iterator