Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #ifdef _ITERATOR_DEBUG_LEVEL
- #undef _ITERATOR_DEBUG_LEVEL
- #define _ITERATOR_DEBUG_LEVEL 0
- #endif
- #include <vector>
- using namespace std;
- int main()
- {
- vector<int> vec{ 1,2,3 };
- auto it = vec.begin();
- cout << *it << endl;
- vec.shrink_to_fit();
- vec.push_back(42);
- cout << *it << endl; // Итератор все еще указывает на старую позицию,
- // и мы точно не знаем, что с тех пор произошло.
- // это не самая корректная запись, мы знаем об этом
- // но для чистоты эксперимента, она здесь!
- }
- #define _ITERATOR_DEBUG_LEVEL 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement