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.

  • @lawmurrayOP
    link
    14 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.