Namespaces
Variants

std::meta::is_structural_type

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 is_structural_type( std::meta::info r );
(since C++26)

Returns true if r is a reflection of a structural type. Otherwise returns false.

Parameters

r - a reflection value

Exceptions

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

Return value

true if r represents a structural type; otherwise false.

Example

#include <meta>

struct S { int x; };
class Bad1 { int x; };
struct Bad2 { mutable int x; };
struct A { int a[2][3]; };
struct B : public S {}; // OK: public base of structural type
struct C : private S {}; // not structural: private base
auto L = [](int n){ return 2 * n; }; // captureless lambda

static_assert( std::meta::is_structural_type(^^int));   // scalar 
static_assert( std::meta::is_structural_type(^^int&));  // lvalue ref
static_assert(!std::meta::is_structural_type(^^int&&)); // rvalue ref is not structural

static_assert( std::meta::is_structural_type(^^S));
static_assert(!std::meta::is_structural_type(^^Bad1));
static_assert(!std::meta::is_structural_type(^^Bad2));
static_assert( std::meta::is_structural_type(^^A));
static_assert( std::meta::is_structural_type(^^B));
static_assert(!std::meta::is_structural_type(^^C));
static_assert( std::meta::is_structural_type(^^decltype(L)));

int main() {}

See also

checks if a type is a structural type
(class template) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.