Namespaces
Variants

std::meta::is_compound_type

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Type properties
Type property queries
 
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

checks if reflected type is an array type
(function) [edit]
checks if reflected type is a function type
(function) [edit]
checks if reflected type is a pointer type
(function) [edit]
checks if reflection represents a member pointer type
(function) [edit]
checks if reflection represents a member object pointer type
(function) [edit]
checks if reflection represents a member function pointer type
(function) [edit]
checks if reflection represents either an lvalue reference or rvalue reference
(function) [edit]
checks if reflected type is a non-union class type
(function) [edit]
checks if reflected type is a union type
(function) [edit]
checks if reflected type is an enumeration type
(function) [edit]
checks if reflection represents a fundamental type
(function) [edit]
checks if reflected type is a scalar type
(function) [edit]
checks if reflected type is an object type
(function) [edit]
checks if a type is a compound type
(class template) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.