blob: 001149c20d21490404f27a5382851cb569f6c65d [file] [log] [blame]
Patrick Williamse0602aa2023-07-17 11:20:00 -05001#pragma once
2
3#include <stdio.h>
4
5#include <format>
6
7// use this until gcc c++ lib has <print>
8namespace std
9{
10inline void vprint(std::FILE* f, std::string_view format, std::format_args args)
11{
12 std::string d = std::vformat(format, args);
13 fwrite(d.data(), 1, d.size(), f);
14}
15template <class... Args>
16inline void print(std::FILE* f, std::format_string<Args...> format,
17 Args&&... args)
18{
19 vprint(f, format.get(), std::make_format_args(std::forward<Args>(args)...));
20}
21template <class... Args>
22inline void print(std::format_string<Args...> format, Args&&... args)
23{
24 vprint(stdout, format.get(),
25 std::make_format_args(std::forward<Args>(args)...));
26}
27} // namespace std