std::meta::is_compound_type
From cppreference.com
| 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
Run this code
#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
(C++26) |
checks if reflected type is an array type (function) |
(C++26) |
checks if reflected type is a function type (function) |
(C++26) |
checks if reflected type is a pointer type (function) |
(C++26) |
checks if reflection represents a member pointer type (function) |
| checks if reflection represents a member object pointer type (function) | |
| checks if reflection represents a member function pointer type (function) | |
(C++26) |
checks if reflection represents either an lvalue reference or rvalue reference (function) |
(C++26) |
checks if reflected type is a non-union class type (function) |
(C++26) |
checks if reflected type is a union type (function) |
(C++26) |
checks if reflected type is an enumeration type (function) |
(C++26) |
checks if reflection represents a fundamental type (function) |
(C++26) |
checks if reflected type is a scalar type (function) |
(C++26) |
checks if reflected type is an object type (function) |
(C++11) |
checks if a type is a compound type (class template) |