Namespaces
Variants

std::is_structural

From cppreference.com
 
 
 
Type traits
Type traits (since C++11)
Type categories
Type properties
(C++14)
(deprecated in C++26)
(until C++20*)
(deprecated in C++20)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(deprecated in C++23)
(deprecated in C++23)
(until C++20*)(C++17)

 
Defined in header <type_traits>
template< class T >
struct is_structural;
(since C++26)

std::is_structural is a UnaryTypeTrait.

If T is a structural type, provides the member constant value equal true. For any other type, value is false.

If the program adds specializations for std::is_structural or std::is_structural_v, the behavior is undefined.

Template parameters

T - a type to check

Helper variable template

template< class T >
constexpr bool is_structural_v = is_structural<T>::value;
(since C++26)

Inherited from std::integral_constant

Member constants

value
[static]
true if T is a structural type, false otherwise
(public static member constant)

Member functions

operator bool
converts the object to bool, returns value
(public member function)
operator()
(C++14)
returns value
(public member function)

Member types

Type Definition
value_type bool
type std::integral_constant<bool, value>

Notes

Feature-test macro Value Std Feature
__cpp_lib_is_structural 202603L (C++26) std::is_structural

Example

#include <type_traits>

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 -n; }; // captureless lambda

static_assert( std::is_structural_v<int>);   // scalar 
static_assert( std::is_structural_v<int&>);  // lvalue ref
static_assert(!std::is_structural_v<int&&>); // rvalue ref
static_assert( std::is_structural_v<S>);
static_assert(!std::is_structural_v<Bad1>);
static_assert(!std::is_structural_v<Bad2>);
static_assert( std::is_structural_v<A>);
static_assert( std::is_structural_v<B>);
static_assert(!std::is_structural_v<C>);
static_assert( std::is_structural_v<decltype(L)>);

int main() { }

See also

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