Skip to content

Prefer pass-by-value over pass-by-rvalue #1046

Closed
@baylesj

Description

@baylesj

I would prefer not specifying rvalue only on the function parameter. It's similarly efficient to have a pass-by-value parameter that you can move in and out of.

If you declare as:
bool insert(ArrayIndex index, Value newValue);

You can call as
Value foo(); insert(index, std::move(foo))

Some good material on this.
http://blogs.microsoft.co.il/sasha/2014/08/21/c-sink-parameter-passing/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions