]> git.proxmox.com Git - ceph.git/blob - ceph/src/include/types_fmt.h
buildsys: change download over to reef release
[ceph.git] / ceph / src / include / types_fmt.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #pragma once
4 /**
5 * \file fmtlib formatters for some types.h classes
6 */
7
8 #include <fmt/format.h>
9
10 #include <string_view>
11
12 #include "include/types.h"
13
14 template <class A, class B, class Comp, class Alloc>
15 struct fmt::formatter<std::map<A, B, Comp, Alloc>> {
16 constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
17
18 template <typename FormatContext>
19 auto format(const std::map<A, B, Comp, Alloc>& m, FormatContext& ctx)
20 {
21 std::string_view sep = "{";
22 for (const auto& [k, v] : m) {
23 fmt::format_to(ctx.out(), "{}{}={}", sep, k, v);
24 sep = ",";
25 }
26 return fmt::format_to(ctx.out(), "}}");
27 }
28 };