ev-fmt-filesystem-path-formatter-002¶
| 字段 | 值 |
|---|---|
| 项目 | fmtlib/fmt |
| 固定 commit | 1be298e1bd68 |
| 路径 | include/fmt/std.h |
| 行段 | L305-L313 |
| 特性 | std::filesystem |
| 许可证 | MIT |
| 代码来源 | 项目源码 |
| 级别 | manual |
| 审核 | zyuhao7 @ 2026-10-24 |
| 测试代码 | 否 |
| 发现方式 | regex |
用法¶
为 std::filesystem::path 特化 formatter
为什么典型¶
库在边界处适配标准类型,调用方无需先转成 string 再格式化,同时保留对齐、宽度与调试格式选项。
摘录¶
template <typename Char> struct formatter<std::filesystem::path, Char> {
private:
format_specs specs_;
detail::arg_ref<Char> width_ref_;
bool debug_ = false;
char path_type_ = 0;
public:
FMT_CONSTEXPR void set_debug_format(bool set = true) { debug_ = set; }
备注¶
生产路径;路径格式化器的类型特化入口。