lets see if this makes thing less slow on windows

This commit is contained in:
Lily Tsuru 2023-08-22 16:57:11 -04:00
parent 7082765060
commit 39e4a4bb90
1 changed files with 10 additions and 0 deletions

View File

@ -5,6 +5,11 @@
#include <cstdio>
#include <format>
#ifdef _WIN32
#define _WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
namespace swbf {
struct FputcIterator {
using iterator_category = std::output_iterator_tag;
@ -30,6 +35,11 @@ namespace swbf {
/// Poor Man's C++23
template<class ...Args>
inline void fprint(std::FILE* file, std::string_view format, Args&&... args) {
#ifdef _WIN32
auto str = std::vformat(format, std::make_format_args(args...));
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), str.data(), str.length(), nullptr, nullptr);
#else
std::vformat_to(FputcIterator(file), format, std::make_format_args(args...));
#endif
}
} // namespace swbf