This patch changes the return type of "Erase-Like Algorithms" to size_type and updates tests accordingly.
For reference P0646R1.
Paths
| Differential D58332
Erase-Like Algorithms Should Return size_type (P0646R1) ClosedPublic Authored by zoecarver on Feb 17 2019, 3:12 PM.
Details
Summary This patch changes the return type of "Erase-Like Algorithms" to size_type and updates tests accordingly. For reference P0646R1.
Diff Detail Event TimelineComment Actions You're going to have to find a different approach here.
This revision now requires changes to proceed.Apr 2 2019, 10:22 PM zoecarver added inline comments.
Comment Actions A meta-question: they're all the same operation under the hood. Comment Actions
And the reason is: Comment Actions
Actually very happy you asked about this, I meant to ask the same thing but forgot.
Comment Actions Committed a modified version as revision 364840 (since I changed the implementation of forward_list::remove_if, etc) This revision is now accepted and ready to land.Jul 1 2019, 12:22 PM Comment Actions Shouldn't the type change be guarded with a conditional compilation construct? I could write std::list<int> l assert(typeid(void) == typeid(l.unique())); and expect this assertion to pass when compiling with, say, -std=c++98. Comment Actions
Yes, it should. I'll fix it. Thanks!
Revision Contents
Diff 193722 include/forward_list
include/list
test/libcxx/diagnostics/nodiscard_extensions.fail.cpp
test/libcxx/diagnostics/nodiscard_extensions.pass.cpp
test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
test/std/containers/sequences/list/list.ops/remove.pass.cpp
test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
test/std/containers/sequences/list/list.ops/unique.pass.cpp
|
This is an expensive operation, it requires traversing the list.
And you're doing it twice - once at the beginning, and once at the end.