|
🛰️航天仿真算法库 SpaceAST 0.3.1
|
#include <Any.hpp>
Public 成员函数 | |
| Any () noexcept=default | |
| Any (const Any &other) | |
| Any (Any &&other) noexcept | |
| template<typename ValueType , typename D = typename std::decay<ValueType>::type, typename std::enable_if<!std::is_same< D, Any >::value &&std::is_copy_constructible< D >::value, int >::type = 0> | |
| Any (ValueType &&value) | |
| Any & | operator= (const Any &other) |
| Any & | operator= (Any &&other) noexcept |
| template<typename ValueType , typename D = typename std::decay<ValueType>::type, typename std::enable_if<!std::is_same< D, Any >::value &&std::is_copy_constructible< D >::value, int >::type = 0> | |
| Any & | operator= (ValueType &&value) |
| bool | has_value () const noexcept |
| const std::type_info & | type () const noexcept |
| void | reset () noexcept |
| template<typename T , typename... Args> | |
| std::enable_if<!std::is_reference< T >::value, T & >::type | emplace (Args &&... args) |
| void | swap (Any &other) noexcept |
友元 | |
| template<typename T > | |
| const T * | any_cast (const Any *operand) |
| template<typename T > | |
| T * | any_cast (Any *operand) |
| template<typename T > | |
| T | any_cast (const Any &operand) |
| template<typename T > | |
| T | any_cast (Any &operand) |
| template<typename T > | |
| T | any_cast (Any &&operand) |
类型擦除的值容器,与 C++17 的 std::any 接口兼容
在任意时刻持有至多一个任意类型的值,或为空。类型在运行时被类型擦除, 通过 any_cast<T>(any) 在已知目标类型时安全地取回。
使用方式:
依赖说明:仅支持具基础对齐(alignof(T) <= alignof(max_align_t))且可拷贝构造的类型; 与 std::any 一致,不存储引用类型。拷贝赋值以 copy-and-swap 提供强异常安全保证。