Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
formatter_macros.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2024, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
5#pragma once
6
25#include "formatter.h"
26#include "convert_string.h"
27
28#include <format>
29
43#define DECLARE_FORMATTER(CLASS_NAME) \
44template <> struct std::formatter<CLASS_NAME> : std::formatter<std::string_view> \
45{ \
46 template <typename FormatContext> \
47 auto format(const CLASS_NAME& item, FormatContext& ctx) const \
48 { \
49 return std::formatter<std::string_view>::format(item.to_string(), ctx); \
50 } \
51}; \
52 \
53template <> \
54struct std::formatter<CLASS_NAME, wchar_t> : std::formatter<std::wstring_view, wchar_t> \
55{ \
56 template <typename FormatContext> \
57 auto format(const CLASS_NAME& item, FormatContext& ctx) const \
58 { \
59 auto str = item.to_string(); \
60 auto wstr = utility_module::convert_string::to_wstring(str); \
61 return std::formatter<std::wstring_view, wchar_t>::format(wstr, ctx); \
62 } \
63};