Spec-Zone.ru › C++

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

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

is_const
(C++26)
checks if reflection represents a const type or a function type with const qualifier
(function)
is_volatile
(C++26)
checks if reflection represents a volatile type or a function type with volatile qualifier
(function)
add_cvadd_constadd_volatile
(C++26)(C++26)(C++26)
adds const and/or volatile qualifiers to reflected type
(function)
remove_cvref
(C++26)
combines meta::remove_cv and meta::remove_reference
(function)
remove_cvremove_constremove_volatile
(C++11)(C++11)(C++11)
removes const and/or volatile qualifiers from the given type
(class template)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/remove_cv

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API