std::remove_cv, std::remove_const, std::remove_volatile
Min standard notice:
Header: <type_traits>
Provides the member typedef type which is the same as T, except that its topmost cv-qualifiers are removed.
# Declarations
template< class T >
struct remove_cv;
(since C++11)
template< class T >
struct remove_const;
(since C++11)
template< class T >
struct remove_volatile;
(since C++11)
# Example
#include <type_traits>
template<typename U, typename V>
constexpr bool same = std::is_same_v<U, V>;
static_assert
(
same<std::remove_cv_t<int>, int> &&
same<std::remove_cv_t<const int>, int> &&
same<std::remove_cv_t<volatile int>, int> &&
same<std::remove_cv_t<const volatile int>, int> &&
// remove_cv only works on types, not on pointers
not same<std::remove_cv_t<const volatile int*>, int*> &&
same<std::remove_cv_t<const volatile int*>, const volatile int*> &&
same<std::remove_cv_t<const int* volatile>, const int*> &&
same<std::remove_cv_t<int* const volatile>, int*>
);
int main() {}