|
CMakeTutorialStep1 2.3.12
|
Classes | |
| struct | Price |
| 价格强类型(整型分),避免与 Quantity 静默混用 More... | |
| struct | Quantity |
| 数量强类型(整型单位) More... | |
Concepts | |
| concept | NamedValue |
| Concept 演示:具名数值类型须暴露 .value 且可转为 int32. | |
Enumerations | |
| enum class | ParseErr : int { empty = 1 , invalid = 2 , overflow = 3 } |
| 价格字符串解析的可恢复错误码 More... | |
Functions | |
| std::expected< Price, ParseErr > | parse_price_cents (std::string_view s) |
| 逐字符解析十进制整数分;空串、非数字或溢出返回对应 ParseErr | |
| std::int64_t | sum_cents (std::span< Price const > prices) noexcept |
| 累加各 Price::cents; noexcept 便于 fuzz/bench 热路径 | |
| std::int64_t | sum_cents (std::span< const Price > prices) noexcept |
| 对价格数组求和(std::span 零拷贝 API) | |
| template<NamedValue T> | |
| constexpr std::int32_t | raw_qty (T t) noexcept |
| 提取 NamedValue 的原始数量值 | |
| double | compute_sqrt (double value) |
| 域检查:非有限、负数或超过 kComputeSqrtMaxInput 时返回 -1.0 | |
| bool | has_numeric_argument (int argc) |
| argc >= 2 即认为用户提供了待计算的数值参数 | |
Variables | |
| constexpr double | kComputeSqrtMaxInput = 1.0e12 |
| 允许的最大输入;超出(或负数 / 非有限)时 compute_sqrt 返回 -1.0 | |
|
strong |
| double tutorial::compute_sqrt | ( | double | value | ) |
域检查:非有限、负数或超过 kComputeSqrtMaxInput 时返回 -1.0
计算非负且不超过 kComputeSqrtMaxInput 的平方根。
| value | 待开平方的输入 |
| bool tutorial::has_numeric_argument | ( | int | argc | ) |
|
nodiscardconstexprnoexcept |
提取 NamedValue 的原始数量值
|
nodiscardnoexcept |
对价格数组求和(std::span 零拷贝 API)
|
noexcept |
累加各 Price::cents; noexcept 便于 fuzz/bench 热路径
|
inlineconstexpr |
允许的最大输入;超出(或负数 / 非有限)时 compute_sqrt 返回 -1.0