commit 7743f77dfec8a722cbeba6aa6b87aa3e4a3903f1
parent c06258fc0d56ebb455ae4394f635c7a2262ceb8c
Author: Oshgnacknak <osh@oshgnacknak.de>
Date: Sat, 25 Dec 2021 12:33:15 +0100
Reintroduce print1(FILE*, T) but using FileFormatter
Diffstat:
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/examples/print.cpp b/examples/print.cpp
@@ -61,5 +61,7 @@ int main() {
osh::println("Printing costume types (see print1 above): ", v);
osh::println("^ Comment it out, error message is ACTUALLY readable");
+ osh::printp(stderr, "Printing to any FILE* other than stdout: ", buf, " - ", v, '\n');
+
return 0;
}
diff --git a/osh.h b/osh.h
@@ -48,6 +48,8 @@ namespace osh {
void print1(Formatter auto&, const double&);
void print1(Formatter auto&, const long double&);
+ template<typename T>
+ void print1(FILE* stream, const T& t);
}
#endif /* OSH_H */
@@ -127,6 +129,12 @@ namespace osh {
fprintf(stream, fmt, args...);
}
+ template<typename T>
+ void print1(FILE* stream, const T& t) {
+ FileFormatter fmt(stream);
+ print1(fmt, t);
+ }
+
}
#endif // OSH_H_IMPLEMENTATION