Skip to content

Why shouldn't we replace _Ref_fn with reference_wrapper? #4027

@frederick-vs-ja

Description

@frederick-vs-ja

In #4025 there's attemption to strengthen the exception specification of _Ref_fn::operator().

Given the standard class template std::reference_wrapper is already a invocable wrapper and its operator() has a propagating exception specification (thanks to LWG-3764), it seems OK to replace the uses of _Ref_fn with reference_wrapper.

Pros:

  • user codes should only use reference_wrapper, so we might be able to instantiate less specializations.

Cons:

  • reference_wrapper is slightly heavier than _Ref_fn;
  • reference_wrapper is assignable, which might be unwanted for the internal details of the implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationRelated to documentation or commentsfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions