Repositories / jai.git

print_compat.h

Clone (read-only): git clone http://git.guha-anderson.com/git/jai.git

Branch
917 bytes · 0ffef26f6c69
// -*-C++-*- #pragma once #include <cstdio> #include <format> #include <string> #include <utility> namespace print_compat { template<typename... Args> void print(FILE *stream, std::format_string<Args...> fmt, Args &&...args) { std::string out = std::format(fmt, std::forward<Args>(args)...); std::fwrite(out.data(), 1, out.size(), stream); } template<typename... Args> void println(FILE *stream, std::format_string<Args...> fmt, Args &&...args) { std::string out = std::format(fmt, std::forward<Args>(args)...); out.push_back('\n'); std::fwrite(out.data(), 1, out.size(), stream); } template<typename... Args> void print(std::format_string<Args...> fmt, Args &&...args) { print(stdout, fmt, std::forward<Args>(args)...); } template<typename... Args> void println(std::format_string<Args...> fmt, Args &&...args) { println(stdout, fmt, std::forward<Args>(args)...); } } // namespace print_compat