cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
toolbox::traits::detail::storage_traits< T > Struct Template Reference

类型存储特征/Storage traits for types More...

#include <type_traits.hpp>

Static Public Attributes

static constexpr bool may_be_heap_allocated
 
static constexpr bool must_be_heap_allocated
 
static constexpr bool may_be_stack_allocated
 

Detailed Description

template<typename T>
struct toolbox::traits::detail::storage_traits< T >

类型存储特征/Storage traits for types

Template Parameters
T要分析的类型/Type to analyze

提供类型的存储特征信息/Provides information about storage characteristics of a type:

  • 是否可以堆分配/Whether it may be heap allocated
  • 是否必须堆分配/Whether it must be heap allocated
  • 是否可以栈分配/Whether it may be stack allocated
class MyClass {};
class Abstract { virtual void foo() = 0; };
// 检查普通类/Check regular class
// 检查抽象类/Check abstract class
static constexpr bool may_be_stack_allocated
Definition type_traits.hpp:106
static constexpr bool must_be_heap_allocated
Definition type_traits.hpp:101

Member Data Documentation

◆ may_be_heap_allocated

template<typename T >
constexpr bool toolbox::traits::detail::storage_traits< T >::may_be_heap_allocated
staticconstexpr
Initial value:
= !std::is_array_v<T>
&& (sizeof(T) > 1024
||
std::has_virtual_destructor_v<T>
||
std::is_polymorphic_v<T>)

◆ may_be_stack_allocated

template<typename T >
constexpr bool toolbox::traits::detail::storage_traits< T >::may_be_stack_allocated
staticconstexpr
Initial value:
=
!must_be_heap_allocated && std::is_object_v<T> && !std::is_abstract_v<T>

◆ must_be_heap_allocated

template<typename T >
constexpr bool toolbox::traits::detail::storage_traits< T >::must_be_heap_allocated
staticconstexpr
Initial value:
=
std::is_abstract_v<T>

The documentation for this struct was generated from the following file: