std::meta::has_static_storage_duration, std::meta::has_thread_storage_duration, std::meta::has_automatic_storage_duration
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 with the specified storage duration.
1) Returns
true if r represents an object or variable with static storage duration; otherwise returns false.
3) Returns
true if r represents a variable with automatic storage duration; otherwise returns false.Parameters
| r | - | a reflection value |
Return value
true if what r represents has the specified storage duration; otherwise false.
Notes
If r does not represent an object or variable, the result is false.
Example
Can be previewed on Compiler Explorer.
#include <meta>
int a;
static_assert(std::meta::has_static_storage_duration(^^a));
static_assert(!std::meta::has_thread_storage_duration(^^a));
static_assert(!std::meta::has_automatic_storage_duration(^^a));
thread_local int b;
static_assert(!std::meta::has_static_storage_duration(^^b));
static_assert(std::meta::has_thread_storage_duration(^^b));
static_assert(!std::meta::has_automatic_storage_duration(^^b));
int main()
{
[[maybe_unused]] int c;
static_assert(!std::meta::has_static_storage_duration(^^c));
static_assert(!std::meta::has_thread_storage_duration(^^c));
static_assert(std::meta::has_automatic_storage_duration(^^c));
}
See also
|
(C++26)(C++26)(C++26)(C++26) | checks if the reflected entity has a linkage (function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/has_storage_duration