Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct A
- {
- A(int a, int b)
- {
- a_ = a;
- b_ = b;
- }
- int a_ = -1;
- int b_ = -2;
- };
- std::list<A> testContainer{{1, 2}, {3, 4}, {5, 6}, {7, 8}};
- auto ptr = testContainer.begin();
- A* ptr2{};
- for (auto iter = testContainer.begin(); iter != testContainer.end(); iter++) {
- if (iter->a_ == 7) {
- ptr2 = &*iter;
- break;
- }
- }
- for (auto iter = testContainer.begin(); iter != testContainer.end(); iter++) {
- if (iter->a_ == 5) {
- testContainer.erase(iter);
- break;
- }
- }
- testContainer.emplace_back(9, 10);
- testContainer.emplace_back(11, 12);
- auto value = *ptr;
- auto value2 = *ptr2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement