Skip to content

enqueue: capture by universal reference #5

Description

@daniel-j-h

Is there a reason the enqueue function doesn't capture the type-deduced function as universal reference? E.g.:

template<typename Function>
auto enqueue(Function&& f) -> std::future<decltype(std::forward<F>(f)())>;

This would allows us to std::forward(f) later on, preserving the rvalue/lvalue type.

This should handle situations nicely where we enqueue

  • rvalues (e.g. anonymous lambdas)
  • lvalues (e.g. named functors)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions