Logo

Programming-Idioms

History of Idiom 135 > diff from v41 to v42

Edit summary for version 42 by programming-idioms.org:
[C++] Variable names items, x

Version 41

2020-09-30, 09:13:10

Version 42

2020-09-30, 09:15:25

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic.
If there are several occurrences of x in items, remove only one of them. If x is absent, keep items unchanged.

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic.
If there are several occurrences of x in items, remove only one of them. If x is absent, keep items unchanged.

Variables
items,x
Variables
items,x
Code
erase(xs, "Mars");
Code
erase(items, x);
Comments bubble
C++20; xs is std::list<>
Comments bubble
C++20
items has type std::list<>
Demo URL
https://godbolt.org/z/jzthR6
Demo URL
https://godbolt.org/z/jzthR6