std::meta::is_structural_type
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 |
Return value
true if r represents a structural type; otherwise false.
Exceptions
Throws std::meta::exception if r does not represent a type or type alias.
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
|
(C++26) | checks if a type is a structural type (class template) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/is_structural_type