Signed-off-by: Samuel Just <sjust@redhat.com>
// vim: ts=8 sw=2 smarttab
#pragma once
+#include <optional>
+
/**
* \file default fmtlib formatters for specifically-tagged types
*/
}
bool verbose{true};
};
+
+template <typename T>
+struct formatter<std::optional<T>> {
+ constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
+ template <typename FormatContext>
+ auto format(const std::optional<T> &v, FormatContext& ctx) const {
+ if (v.has_value()) {
+ return fmt::format_to(ctx.out(), "{}", *v);
+ }
+ return fmt::format_to(ctx.out(), "<null>");
+ }
+};
+
} // namespace fmt
}
}
-template <typename T>
-struct fmt::formatter<std::optional<T>> : fmt::formatter<T> {
- template <typename FormatContext>
- auto format(const std::optional<T>& v, FormatContext& ctx) const {
- if (v.has_value()) {
- return fmt::formatter<T>::format(*v, ctx);
- }
- return fmt::format_to(ctx.out(), "<null>");
- }
-};
-
namespace crimson::osd {
using crimson::common::local_conf;