std::meta::has_static_storage_duration, std::meta::has_thread_storage_duration, std::meta::has_automatic_storage_duration - cppreference.com
Namespaces
Variants

std::meta::has_static_storage_duration, std::meta::has_thread_storage_duration, std::meta::has_automatic_storage_duration

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Reflection queries
Reflection layout queries
Type properties
Type property queries
 
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.
2) Returns true if r represents a variable with thread 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