Spec-Zone.ru › C++

std::meta::is_compound_type

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

Returns true if r represents a compound type (that is, array, function, object pointer, function pointer, member object pointer, member function pointer, reference, class, union, or enumeration, including any cv-qualified variants). Otherwise returns false.

Parameters

r - a reflection value

Return value

true if r represents a compound type; otherwise false.

Exceptions

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

Example

#include <meta>

static_assert(not is_compound_type(^^int));
static_assert(is_compound_type(^^int*));
static_assert(is_compound_type(^^int&));

void f();
static_assert(is_compound_type(^^decltype(f)));
static_assert(is_compound_type(^^decltype(&f)));

static_assert(is_compound_type(^^char[100]));

class C {};
static_assert(is_compound_type(^^C));

union U {};
static_assert(is_compound_type(^^U));

enum struct E { e };
static_assert(is_compound_type(^^E));
static_assert(is_compound_type(^^decltype(E::e)));

struct S
{
    int i : 8;
    int j;
    void foo();
};
static_assert(not is_compound_type(^^decltype(S::i)));
static_assert(not is_compound_type(^^decltype(S::j)));
static_assert(is_compound_type(^^decltype(&S::j)));
static_assert(is_compound_type(^^decltype(&S::foo)));

int main() {}

See also

is_array_type
(C++26)
checks if reflected type is an array type
(function)
is_function_type
(C++26)
checks if reflected type is a function type
(function)
is_pointer_type
(C++26)
checks if reflected type is a pointer type
(function)
is_member_pointer_type
(C++26)
checks if reflection represents a member pointer type
(function)
is_member_object_pointer_type
(C++26)
checks if reflection represents a member object pointer type
(function)
is_member_function_pointer_type
(C++26)
checks if reflection represents a member function pointer type
(function)
is_reference_type
(C++26)
checks if reflection represents either an lvalue reference or rvalue reference
(function)
is_class_type
(C++26)
checks if reflected type is a non-union class type
(function)
is_union_type
(C++26)
checks if reflected type is a union type
(function)
is_enum_type
(C++26)
checks if reflected type is an enumeration type
(function)
is_fundamental_type
(C++26)
checks if reflection represents a fundamental type
(function)
is_scalar_type
(C++26)
checks if reflected type is a scalar type
(function)
is_object_type
(C++26)
checks if reflected type is an object type
(function)
is_compound
(C++11)
checks if a type is a compound type
(class template)

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

Spec-Zone.ru

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