|
🛰️航天仿真算法库 SpaceAST 0.0.1
|
#include <VariantVector.hpp>
类 | |
| struct | TypeOps |
Public 成员函数 | |
| VariantVector (const VariantVector &other) | |
| VariantVector & | operator= (const VariantVector &other) |
| VariantVector (VariantVector &&other) noexcept | |
| VariantVector & | operator= (VariantVector &&other) noexcept |
| size_t | size () const noexcept |
| size_t | capacity () const noexcept |
| bool | empty () const noexcept |
| const std::type_info & | elementType () const noexcept |
| bool | hasType () const noexcept |
| size_t | elementSize () const noexcept |
| const TypeOps * | ops () const noexcept |
| void * | data () noexcept |
| const void * | data () const noexcept |
| template<typename T > | |
| void | reserve (size_t n) |
| template<typename T > | |
| void | resize (size_t n) |
| template<typename T > | |
| void | resize (size_t n, const T &value) |
| template<typename T > | |
| void | reset (size_t n) |
| template<typename T > | |
| void | reset (size_t n, const T &value) |
| template<typename T > | |
| void | pushBack (const T &value) |
| template<typename T , typename... Args> | |
| void | emplaceBack (Args &&... args) |
| void | clear () |
| void | shrinkToFit () |
| template<typename T > | |
| T * | as () |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| Span< T > | asSpan () |
| template<typename T > | |
| Span< const T > | asSpan () const |
| template<typename T > | |
| T & | at (size_t i) |
| template<typename T > | |
| const T & | at (size_t i) const |
| template<typename T > | |
| T * | begin () |
| template<typename T > | |
| const T * | begin () const |
| template<typename T > | |
| T * | end () |
| template<typename T > | |
| const T * | end () const |
| void | swap (VariantVector &other) noexcept |
静态 Public 成员函数 | |
| template<typename T > | |
| static VariantVector | fromVector (const std::vector< T > &vec) |
变类型向量容器
该类可以存储不同数据类型的向量,无需在编译时指定具体类型, 但一次只能存储一种特定类型的数据。
类型元数据(TypeOps*、type_info*、elementSize)嵌入在分配块头部, data_ 指针永远指向第一个元素。data_ == nullptr 表示未设置类型。
使用方式: