std::meta::has_static_storage_duration, std::meta::has_thread_storage_duration, std::meta::has_automatic_storage_duration
From cppreference.com
| Defined in header <meta>
|
||
consteval bool has_static_storage_duration( std::meta::info r );
|
(1) | (since C++26) |
consteval bool has_thread_storage_duration( std::meta::info r );
|
(2) | (since C++26) |
consteval bool has_automatic_storage_duration( std::meta::info r );
|
(3) | (since C++26) |
Determines if r represents an object or variable that has the specified storage duration.
Returns true if r represents an entity that has
Otherwise, returns false.
Parameters
| r | - | a reflection value |
Return value
true if r represents an object or variable with respective storage duration; otherwise false.
Notes
It is not possible to have a reflection representing an object or variable having dynamic storage duration.
Example
Run this code
#include <meta>
int g{'_'};
static_assert(has_static_storage_duration(^^g));
static_assert(!has_thread_storage_duration(^^g));
static_assert(!has_automatic_storage_duration(^^g));
template<class T>
struct S
{
thread_local inline static int m{42};
};
static_assert(!has_static_storage_duration(^^S<float>::m));
static_assert(has_thread_storage_duration(^^S<float>::m));
static_assert(!has_automatic_storage_duration(^^S<float>::m));
int main(int argc, const char*[])
{
static_assert(!has_static_storage_duration(^^argc));
static_assert(!has_thread_storage_duration(^^argc));
static_assert(has_automatic_storage_duration(^^argc));
}
See also
(C++26) |
checks if reflection represents a static object (function) |
(C++26) |
checks if reflection represents a variable (function) |