Does it matter in which order the following is applied ?
std::remove_reference_t<std::remove_cv_t<T>>
or
std::remove_cv_t<std::remove_reference_t<T>>
In what scenario, if any, does the order matter ?
There are cases when these two type traits produce different results. For example, let's consider T = const int&.
std::remove_cv_t will remove top-level cv-qualifier, turning const int& into const int&, because there is no top-level cv-qualifier. std::remove_reference_t will then return const int.
In the second case, std::remove_reference_t will return const int, and std::remove_cv_t will transform it into int.
Simple demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With