Namespaces
Variants

std::meta::remove_const, std::meta::remove_volatile, std::meta::remove_cv

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Type properties
Type property queries
 
Defined in header <meta>
consteval std::meta::info remove_const( std::meta::info r );
(1) (since C++26)
consteval std::meta::info remove_volatile( std::meta::info r );
(2) (since C++26)
consteval std::meta::info remove_cv( std::meta::info r );
(3) (since C++26)

Returns a reflection of the type T represented by r, except that the type's topmost cv-qualifiers are removed.

1) Removes the topmost const qualifier (if present). Equivalent to
return std::meta::dealias(^^std::remove_const_t<T>);.
2) Removes the topmost volatile qualifier (if present). Equivalent to
return std::meta::dealias(^^std::remove_volatile_t<T>);.
3) Removes the topmost const, or the topmost volatile, or both qualifiers (if present). Equivalent to
return std::meta::dealias(^^std::remove_cv_t<T>);.

Parameters

r - a reflection value

Return value

A reflection of the type represented by r with its topmost cv-qualifiers removed appropriately.

Exceptions

Throws std::meta::exception if r does not represent a type or type alias.

Example

#include <meta>

static_assert
(""
    && (remove_cv(^^int) == ^^int)
    && (remove_cv(^^const int) == ^^int)
    && (remove_cv(^^volatile int) == ^^int)
    && (remove_cv(^^const volatile int) == ^^int)
    // remove_cv only works on types, not on pointers
    && (remove_cv(^^const volatile int*) != ^^int*)
    && (remove_cv(^^const volatile int*) == ^^const volatile int*)
    && (remove_cv(^^const int* volatile) == ^^const int*)
    && (remove_cv(^^int* const volatile) == ^^int*)
);

int main() {}

See also

(C++26)
checks if reflection represents a const type or a function type with const qualifier
(function) [edit]
checks if reflection represents a volatile type or a function type with volatile qualifier
(function) [edit]
(C++26)(C++26)(C++26)
adds const and/or volatile qualifiers to reflected type
(function) [edit]
combines meta::remove_cv and meta::remove_reference
(function) [edit]
removes const and/or volatile qualifiers from the given type
(class template) [edit]