FreeBSD Bugzilla – Attachment 145205 Details for
Bug 192303
C++11 std::list<>::remove_if() visits elements multiple times
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Bug demo
main.cpp (text/x-c++src), 703 bytes, created by
kamikaze
on 2014-08-01 10:00:11 UTC
(
hide
)
Description:
Bug demo
Filename:
MIME Type:
Creator:
kamikaze
Created:
2014-08-01 10:00:11 UTC
Size:
703 bytes
patch
obsolete
>#include <iostream> >#include <iomanip> >#include <list> > >using std::cout; >using std::setw; >using std::list; > >int main() { > cout << "Initial list:"; > > /* Reference list: 0 ... 9 */ > list<int> demo(10); > int i = 0; > for (auto &val : demo) { > val = i++; > cout << ' ' << val; > } > > cout << "\nRemove odd numbers ...\n"; > > /* Remove odd numbers. */ > int visits = 0; > cout << "| val | remove\n" > "|-----|--------\n"; > demo.remove_if([&](int val) -> bool { > cout << "| " << setw(3) << val > << " | " << (val % 2 ? "X\n" : "\n"); > visits++; > return val % 2; > }); > > cout << "Updated list:"; > for (auto val : demo) { > cout << ' ' << val; > } > cout << "\nVisits: " << visits << '\n'; > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 192303
: 145205 |
145275