以下列顺序应用是否重要?
std::remove_reference_t<std::remove_cv_t<T>>
或
std::remove_cv_t<std::remove_reference_t<T>>
在什么情况下,订单有关系吗?
在某些情况下,这两种类型的特征产生不同的结果。例如,让我们考虑T = const int&
。
std::remove_cv_t
将删除顶级cv限定词,将const int&
转换为const int&
,因为没有顶级cv限定词。 std::remove_reference_t
然后将返回const int
。
在第二种情况下,std::remove_reference_t
将返回const int
,并且std::remove_cv_t
会将其转换为int
。