|
Console Library 8.0.0
A header-only library that makes C++ simple
|
#include <box.h>
Public Member Functions | |
| template<class... Args> | |
| Box (Args &&...args) | |
| 从任意数量、任意类型的值构造 Box。 | |
| template<class T> | |
| T & | get (size_t index) |
| 类型安全地获取指定索引处的元素(非常量版本)。 | |
| template<class T> | |
| const T & | get (size_t index) const |
| 类型安全地获取指定索引处的元素(常量版本)。 | |
| template<class T> | |
| T & | unsafe_get (size_t index) |
| 不安全地获取指定索引处的元素(非常量版本)。 | |
| template<class T> | |
| const T & | unsafe_get (size_t index) const |
| 不安全地获取指定索引处的元素(常量版本)。 | |
| template<class... Args> | |
| void | unpack (Args &...args) const |
| 将 Box 中的元素按顺序解包到多个变量中(类型安全)。 | |
| template<class... Args> | |
| void | unsafe_unpack (Args &...args) const |
| 将 Box 中的元素按顺序解包到多个变量中(不安全版本)。 | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Box &box) |
| 将 Box 输出到流,格式类似于元组 (elem1, elem2, ...)。 | |
| std::wostream & | operator<< (std::wostream &os, const Box &box) |
| 将 Box 输出到宽字符流。 | |
存储多个 Item 的异构容器。
公有继承自 std::vector<Item>,支持从多个任意类型的值直接构造, 并提供类型安全的元素访问和解包功能。
|
inlineexplicit |
|
inline |
类型安全地获取指定索引处的元素(非常量版本)。
| T | 期望的类型。 |
| index | 元素索引(从 0 开始)。 |
| console::IndexError | 若索引越界。 |
| console::TypeError | 若实际类型与 T 不匹配。 |
|
inline |
类型安全地获取指定索引处的元素(常量版本)。
| T | 期望的类型。 |
| index | 元素索引(从 0 开始)。 |
| console::IndexError | 若索引越界。 |
| console::TypeError | 若实际类型与 T 不匹配。 |
|
inline |
|
inline |
不安全地获取指定索引处的元素(非常量版本)。
| T | 期望的类型(必须与实际类型匹配,否则 UB)。 |
| index | 元素索引(从 0 开始)。 |
|
inline |
不安全地获取指定索引处的元素(常量版本)。
| T | 期望的类型(必须与实际类型匹配,否则 UB)。 |
| index | 元素索引(从 0 开始)。 |
|
inline |
|
friend |
|
friend |