Open
Conversation
4156a67 to
a80ff2a
Compare
a80ff2a to
da75c3b
Compare
Author
|
By the way I see removal of these moves a prerequisite for supporting non-moveable callables as suggested in #31 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@Naios
Hi, I noticed constructing function involves at least three moves of my callable. In my use-case an extra move costs 150ns+.
One of the extra moves is easy to avoid by forwarding a reference to constructor of box. The other extra move caused by that box being temporary before a move into vtable_t is harder to remove. I'm not addressing it in this PR.
What was a problem?
Since box::box accepts T by value, make_box contructs a temporary T when passing callable to constructor of box.
How this PR fixes the problem?
I replace
box::box(T, Allocator)with two overloads:box::box(const T&, Allocator)andbox::box(T&&, Allocator).This way user-provided lvalue- or rvalue-reference gets forwarded all the way to construction of
box::value_.Check lists (check
xin[ ]of list items)Additional Comments (if any)