Spec-Zone.ru › C++

std::meta::is_class_type

Defined in header <meta>
consteval bool is_class_type( std::meta::info r );
(since C++26)

Returns true if r represents a non-union class type. Otherwise returns false.

Parameters

r - a reflection value

Return value

true if r represents a non-union class type; otherwise false.

Exceptions

Throws std::meta::exception if r does not represent a type or type alias.

Example

#include <meta>

struct S {};
static_assert(!is_union_type(^^S));
static_assert(is_class_type(^^S));

union U
{
    int a;
    float b;
};
static_assert(is_union_type(^^U));
static_assert(!is_class_type(^^U));

struct C { U u; };
static_assert(!is_union_type(^^C));
static_assert(is_class_type(^^C));

static_assert(!is_class_type(^^int));

static_assert(is_class_type(^^struct I), "incomplete class");
static_assert(is_class_type(^^class II), "incomplete class");

static_assert(is_class_type(^^decltype([]{})));

int main() {}

See also

is_union_type
(C++26)
checks if reflected type is a union type
(function)
is_class
(C++11)
checks if a type is a non-union class type
(class template)
is_union
(C++11)
checks if a type is a union type
(class template)

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

Spec-Zone.ru

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