Patrick Williams | e0602aa | 2023-07-17 11:20:00 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | #include <format> |
| 6 | |
| 7 | // use this until gcc c++ lib has <print> |
| 8 | namespace std |
| 9 | { |
| 10 | inline 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 | } |
| 15 | template <class... Args> |
| 16 | inline 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 | } |
| 21 | template <class... Args> |
| 22 | inline 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 |