Skip to content

[Question] Why don't we use perfect forward for TypedFunction? #261

@DarkSharpness

Description

@DarkSharpness

template <typename FLambda,
typename = std::enable_if_t<std::is_convertible_v<FLambda, std::function<R(Args...)>>>>
TypedFunction(const FLambda& typed_lambda) { // NOLINT(*)
packed_ = Function::FromTyped(typed_lambda);
}

When constructed from C++ functions, this will lead to one unnecessary copy. A quick example is the code in PR #228 (support for STL), where we construct TypedFunction from native C++ functions.

A (hopefully) better implementation can be use perfect forwarding for all types except for TypeFunction itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions