| 你需要 | 用这个 | 别用这个 |
|---|---|---|
| 一种类型,可能不存在 | optional<T> |
pair<bool, T> 或特殊值 -1 |
| 多种类型,但只有编译期已知的几种 | variant<A, B, C> |
union 或 void* |
| 每一种可能的类型(运行时才确定) | any |
void* |
| 只读字符串参数 | string_view |
const string&(可能触发分配) |
| 连续内存只读参数 | span<const T> |
(T*, size_t) |
| 类型安全格式化 | format |
printf 或 ostringstream |