这是我的代码:
#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>]()'
。
我无法弄清楚迭代器差异是如何突然停止工作的!我在这里错过了什么吗?