preCICE v3.1.2
Loading...
Searching...
No Matches
fmtSTL.hpp
Go to the documentation of this file.
1#include <array>
2#include <deque>
3#include <fmt/format.h>
4#include <map>
5#include <set>
6#include <vector>
7
8template <class T, class Allocator>
9struct fmt::formatter<std::vector<T, Allocator>> : formatter<string_view> {
11 template <typename FormatContext>
12 auto format(const std::vector<T, Allocator> &v, FormatContext &ctx) const
13 {
14 return format_to(ctx.out(), "[{}]", fmt::join(v, ", "));
15 }
16};
17
18template <class T, class Allocator>
19struct fmt::formatter<std::deque<T, Allocator>> : formatter<string_view> {
21 template <typename FormatContext>
22 auto format(const std::deque<T, Allocator> &v, FormatContext &ctx) const
23 {
24 return format_to(ctx.out(), "[{}]", fmt::join(v, ", "));
25 }
26};
27
28template <class T, std::size_t n>
29struct fmt::formatter<std::array<T, n>> : formatter<string_view> {
31 template <typename FormatContext>
32 auto format(const std::array<T, n> &v, FormatContext &ctx) const
33 {
34 return format_to(ctx.out(), "[{}]", fmt::join(v, ", "));
35 }
36};
37
38template <class T, class Compare, class Allocator>
39struct fmt::formatter<std::set<T, Compare, Allocator>> : formatter<string_view> {
41 template <typename FormatContext>
42 auto format(const std::set<T, Compare, Allocator> &s, FormatContext &ctx) const
43 {
44 return format_to(ctx.out(), "{{{}}}", fmt::join(s, ", "));
45 }
46};
47
48template <class T, class Compare, class Allocator>
49struct fmt::formatter<std::map<T, Compare, Allocator>> : formatter<string_view> {
51 template <typename FormatContext>
52 auto format(const std::map<T, Compare, Allocator> &s, FormatContext &ctx) const
53 {
54 return format_to(ctx.out(), "({})", fmt::join(s, ", "));
55 }
56};
57
58template <class F, class S>
59struct fmt::formatter<std::pair<F, S>> : formatter<string_view> {
61 template <typename FormatContext>
62 auto format(const std::pair<F, S> &p, FormatContext &ctx) const
63 {
64 return format_to(ctx.out(), "({}, {})", p.first, p.second);
65 }
66};
STL namespace.
auto format(const std::array< T, n > &v, FormatContext &ctx) const
Formats arrays like [ l, i, s, t, s ].
Definition fmtSTL.hpp:32
auto format(const std::deque< T, Allocator > &v, FormatContext &ctx) const
Formats dequeues like [ l, i, s, t, s ].
Definition fmtSTL.hpp:22
auto format(const std::map< T, Compare, Allocator > &s, FormatContext &ctx) const
Formats maps like tuples ( (k1, v1), (k2, v2) )
Definition fmtSTL.hpp:52
auto format(const std::pair< F, S > &p, FormatContext &ctx) const
Formats pairs like tuples ( first, second )
Definition fmtSTL.hpp:62
auto format(const std::set< T, Compare, Allocator > &s, FormatContext &ctx) const
Formats sets like { s, e, t, s}.
Definition fmtSTL.hpp:42
auto format(const std::vector< T, Allocator > &v, FormatContext &ctx) const
Formats vectors like [ l, i, s, t, s ].
Definition fmtSTL.hpp:12