CCF
Loading...
Searching...
No Matches
enum_formatter.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
5#define FMT_HEADER_ONLY
6#include <fmt/format.h>
7
12FMT_BEGIN_NAMESPACE
13template <typename E>
14struct formatter<E, std::enable_if_t<std::is_enum_v<E>, char>>
15{
16 template <typename ParseContext>
17 constexpr auto parse(ParseContext& ctx)
18 {
19 return ctx.begin();
20 }
21
22 template <typename FormatContext>
23 auto format(const E& value, FormatContext& ctx) const
24 {
25 return fmt::format_to(
26 ctx.out(), "{}", static_cast<std::underlying_type_t<E>>(value));
27 }
28};
29FMT_END_NAMESPACE
30
31// ci-checks exception - defines a struct in the fmt namespace
32namespace ccf
33{}
Definition app_interface.h:14
STL namespace.
constexpr auto parse(ParseContext &ctx)
Definition enum_formatter.h:17
auto format(const E &value, FormatContext &ctx) const
Definition enum_formatter.h:23