1 2 3 4 5 6 7 8 9 10 11 12 | #include <list> int main() { std::list<int> list ; list.push_back(1) ; list.push_back(2) ; auto it = list.begin() ; ++it ; unsigned position = it - list.begin() ; } |
I2luY2x1ZGUgPGxpc3Q+CgppbnQgbWFpbigpCnsKICAgIHN0ZDo6bGlzdDxpbnQ+IGxpc3QgOwogICAgbGlzdC5wdXNoX2JhY2soMSkgOwogICAgbGlzdC5wdXNoX2JhY2soMikgOwoKICAgIGF1dG8gaXQgPSBsaXN0LmJlZ2luKCkgOwogICAgKytpdCA7CiAgICB1bnNpZ25lZCBwb3NpdGlvbiA9IGl0IC0gbGlzdC5iZWdpbigpIDsKfQ==
prog.cpp: In function 'int main()': prog.cpp:11:41: error: no match for 'operator-' in 'it - list.std::list<_Tp, _Alloc>::begin [with _Tp = int, _Alloc = std::allocator<int>, std::list<_Tp, _Alloc>::iterator = std::_List_iterator<int>]()'
-
result: Compilation error (maybe you wish to see an example for C++11)


