From f9da4640c4098107aefc6c02b12b543384cccc50 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 30 Apr 2026 09:35:03 +0300 Subject: Drop libfmt We can use std::format() and a custom print() wrapper with C++20. When moving to C++23, we can drop the wrapper. Signed-off-by: Tomi Valkeinen --- kms++/inc/kms++/format.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 kms++/inc/kms++/format.h (limited to 'kms++/inc') diff --git a/kms++/inc/kms++/format.h b/kms++/inc/kms++/format.h new file mode 100644 index 0000000..b48babe --- /dev/null +++ b/kms++/inc/kms++/format.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include + +// This can be removed when moving to C++23. For now, this gives us +// fmt::format() and fmt::print(). + +namespace fmt { + +using std::format; + +template +void print(std::format_string fmtstr, Args&&... args) +{ + std::string s = std::format(fmtstr, std::forward(args)...); + std::fwrite(s.data(), 1, s.size(), stdout); +} + +template +void print(std::FILE* f, std::format_string fmtstr, Args&&... args) +{ + std::string s = std::format(fmtstr, std::forward(args)...); + std::fwrite(s.data(), 1, s.size(), f); +} + +} // namespace fmt -- cgit v1.2.3