Consider, for example,
#include <type_traits> int main() { static_assert(std::is_same_v< std::decay_t<const int&>, std::remove_reference_t<const int&> >); // int != const int }
std::decay will remove any cv-qualifer, remove_reference will not. It will simply separate the "reference" part of the type.
From reference :
Applies the value of lvalue-to-rvalue, array-to-pointer, and function-to-pointer implicit conversions of type T, removes the cv qualifiers, and defines the resulting type as the type of the typedef member.
Therefore, std::decay will do more type conversions than std::remove_reference .
There are also type modifiers for more nuanced applications that will only perform parts of the set of possible decay transformations, for example, remove_cv , remove_volatile or, in C ++ 20, remove_cvref .
source share