std::meta::is_const
Defined in header <meta> | ||
|---|---|---|
consteval bool is_const( std::meta::info r ); | (since C++26) |
Let T be std::meta::type_of(r) if has-type(r) is true. Otherwise, let T be std::meta::dealias(r).
Returns: true if T represents a const (or const volatile) type, or a const-qualified function type. Otherwise, false.
Parameters
| r | - | a reflection value |
Return value
true if T represents a const type, or a const-qualified function type. Otherwise, false.
Example
#include <meta>
void foo();
struct S
{
void bar() const;
void pub();
};
const int a{42};
int b{};
static_assert(!is_const(^^foo));
static_assert( is_const(^^S::bar));
static_assert(!is_const(^^S::pub));
static_assert( is_const(^^a));
static_assert(!is_const(^^b));
int main() {}
See also
|
(C++11) | checks if a type is const-qualified (class template) |
|
(C++26)(C++26)(C++26) | adds const and/or volatile qualifiers to reflected type (function) |
|
(C++26)(C++26)(C++26) | removes const and/or volatile qualifiers from reflected type (function) |
|
(C++11)(C++11)(C++11) | adds const and/or volatile qualifiers to the given type (class template) |
|
(C++11)(C++11)(C++11) | removes const and/or volatile qualifiers from the given type (class template) |
|
(C++17) | obtains a reference to const to its argument (function template) |
|
(C++23) | converts a view into a constant_range(class template) (range adaptor object) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/is_const