acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
_iostream.h
1#pragma once
2
3
4#if defined(__STD_FORMAT__)
5
6
7// Created by speccylad(twitch)/turd(discord) 2023-10-27 ~09:00 BRT
8
9
10//#ifdef __STD_FORMAT__
11
12
13#include <format>
14#include <iostream>
15#include <string>
16#include <utility>
17
18#include "framework.h"
19
20//
23//template<>
24//struct std::formatter<::string> : std::formatter<std::string> {
25// template<class FormatContext>
26// auto format(const ::string& value, FormatContext& fc) const
27// {
28// return std::formatter<std::string>::format(value.c_str(), fc);
29// }
30//};
31
32// NOTE: "fmt" is marked as const in all of these function declarations
33// because std::format() also does this. I'm just following what they've
34// done as I assume there's good reason.
35
36//template<typename... Ts>
37//inline ::string format(const std::format_string<Ts...> fmt, Ts&&... args) {
38// return ::string(std::format(fmt, std::forward<Ts>(args)...));
39//}
40
41
42// print formatted output to std::cout without a newline
43template<typename... Ts>
44inline void print(const std::format_string<Ts...> fmt, Ts&&... args) {
45 const auto _Fmtd = std::format(fmt, std::forward<Ts>(args)...);
46 std::cout << _Fmtd;
47}
48
49
50// print formatted output to std::cout with a newline
51template<typename... Ts>
52inline void println(const std::format_string<Ts...> fmt, Ts&&... args) {
53 const auto _Fmtd = std::format(fmt, std::forward<Ts>(args)...);
54 std::cout << _Fmtd << '\n';
55}
56
57
58// print formatted output to std::cerr without a newline
59template<typename... Ts>
60inline void eprint(const std::format_string<Ts...> fmt, Ts&&... args) {
61 const auto _Fmtd = std::format(fmt, std::forward<Ts>(args)...);
62 std::cerr << _Fmtd;
63}
64
65// print formatted output to std::cerr with a newline
66template<typename... Ts>
67inline void eprintln(const std::format_string<Ts...> fmt, Ts&&... args) {
68 const auto _Fmtd = std::format(fmt, std::forward<Ts>(args)...);
69 std::cerr << _Fmtd << '\n';
70}
71
72
73#endif // __STD_FORMAT__
74
75
76