Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Created by Barthap on 2019-01-22.
- //
- #include <utility>
- #include <iostream>
- #include <vector>
- #include <list>
- int main()
- {
- std::list<int> lista = {1,2,3,4,5};
- for(auto& e : lista)
- std::cout << e << " ";
- std::cout << std::endl;
- auto it = std::find(lista.begin(), lista.end(), 4);
- int &ref = *it;
- std::cout << "ref = " << ref << std::endl;
- //std::remove_if(lista.begin(), lista.end(), [](auto& el) { return el == 2; });
- lista.remove_if([](auto& el) { return el == 2; });
- std::cout << "after remove, ref = " << ref << std::endl;
- auto it2 = std::find(lista.begin(), lista.end(), 4);
- std::cout << "Original address: " << std::addressof(ref)
- << "\nAfter remove: " << std::addressof(*it2) << std::endl;
- ref = 16;
- for(auto& e : lista)
- std::cout << e << " ";
- std::cout << std::endl;
- }
Add Comment
Please, Sign In to add comment