commit accc4ba9be305c87a087a70db2bc94886eb656f6
parent fdcf1e2e1a12b1cf8d857db4bf7bf45f6ee6363a
Author: Oshgnacknak <osh@oshgnacknak.de>
Date: Sun, 23 Jan 2022 18:02:37 +0100
Add eprint and eprintln
Diffstat:
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/examples/print.cpp b/examples/print.cpp
@@ -11,7 +11,8 @@ void print1(Formatter auto& fmt, Vector2& v) {
}
int main() {
- println("Hallo, Welt");
+ print("Hallo, Welt -");
+ println(" Hello, World!");
println("Concatinating different data types:",
'-', 5, 6.0d, 9, '+', 'L');
@@ -78,7 +79,8 @@ int main() {
println("Printing costume types (see print1 above): ", v);
println("^ Comment it out, error message is ACTUALLY readable");
- printp(ferr, "Printing to stderr: ", "you error is soos ", d, f, '\n');
+ eprint("Printing to stderr: ", "you error is soos ", d, f);
+ eprintln(" and here some saas");
FileFormatter fmt(stderr);
printp(fmt, "Printing to any FILE* other than stdout: ", buf, " - ", v, '\n');
diff --git a/osh.h b/osh.h
@@ -43,6 +43,11 @@ namespace osh {
template<PrintableTo<FileFormatter>... Args>
void println(Args&&...);
+ template<PrintableTo<FileFormatter>... Args>
+ void eprint(Args&&...);
+ template<PrintableTo<FileFormatter>... Args>
+ void eprintln(Args&&...);
+
void print1(Formatter auto&, const char*);
void print1(Formatter auto&, char*);
template<typename T> void print1(Formatter auto&, const T*);
@@ -208,6 +213,16 @@ namespace osh {
printp(fout, args..., '\n');
}
+ template<PrintableTo<FileFormatter>... Args>
+ void eprint(Args&&... args) {
+ printp(ferr, args...);
+ }
+
+ template<PrintableTo<FileFormatter>... Args>
+ void eprintln(Args&&... args) {
+ printp(ferr, args..., '\n');
+ }
+
FileFormatter fout(stdout);
FileFormatter ferr(stderr);