this post was submitted on 27 Jan 2024
12 points (100.0% liked)

C++

1763 readers
1 users here now

The center for all discussion and news regarding C++.

Rules

founded 1 year ago
MODERATORS
 

The intersection of forwarding references and overload resolution has been bugging me, and I've been caught out a few times on the wrong overload, so here's an idea.

you are viewing a single comment's thread
view the rest of the comments
[–] lawmurray@programming.dev 1 points 8 months ago

Yes, std::remove_cvref_t combines the other two, in fact I believe it does so precisely (see the "Possible Implementation" on cppreference.com). The "...with a little extra" that I mention for std::decay_t in the article is that it does the same as std::remove_cvref_t plus some standardization of array and function types to pointer types (again, see the "Possible implementation" of it on cppreference.com). For my purposes it doesn't really matter which to use, and I mostly prefer std::decay_t for its brevity.