lundi 18 décembre 2017

Difference between std::decay and std::remove_reference

When template metaprogramming in C++, I often run into something like the following:

template <typename T>
S<T> make_wrapper(T&& t) { return S<T>(std::forward<T>(t)); }

I know I should use something like std::decay in the return type, but why wouldn't std::remove_reference work as well? What's the difference here? What about std::remove_cvref?

Aucun commentaire:

Enregistrer un commentaire