-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cosmetics: given pairs of overloads for
const T&
and T&&
, when `T…
…` is specified explicitly rather than inferred and when it can itself be a reference, arrange for the first overload to be excluded for rvalue references, and for the second one to be excluded for lvalue references. This used to be done by the `T&&` overload handling both lvalue and rvalue references. For lvalue references it is crucial to exclude one of the overloads, because they collapse to the same signature. Handling lvalue references by `const T&` is more elegant than by `T&&`, because it matches how they work for `T` being a non-reference, and because otherwise we need to remember to use `std::forward()` in the `T&&` overload, even in case when this is not a function templatized over `T` but a regular member function of a class templatized over `T`. For rvalue references it is still nice to exclude the `const T&` overload, because it should never be taken anyway when the other overload is a better match. PiperOrigin-RevId: 605621946
- Loading branch information
Showing
1 changed file
with
31 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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