Namespaces
Variants
Views
Actions

Talk:cpp/container/vector/erase2

From cppreference.com

https://ch.cppreference.com/w/cpp/container/vector/erase2

Output: Init: 0 1 2 3 4 5 6 7 8 9 Erase '3': 0 1 2 4 5 6 7 8 9 Erase all even numbers: 1 5 7 9 In all 5 even numbers were erased.

The number 5 should be changed to 1 in the last line. Or modify `std::erase_if(cnt, [](char x) { return (x - '0') % 2 == 0; });` to `erased = std::erase_if(cnt, [](char x) { return (x - '0') % 2 == 0; });`

You right, erased = was missing. Now it is fixed by copying the updated example and can be checked e.g. here: 示例. Thank you.)  Done --Space Mission (talk) 16:13, 27 June 2022 (PDT)