summaryrefslogtreecommitdiff
path: root/lib/utils/mu-utils.hh
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2023-08-11 19:55:43 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2023-08-11 19:57:00 +0300
commit11df0bedce20d7fe75cb04a3d0a886e5748c3451 (patch)
treef85631e98895b303574efdf394d1d09e64d7238d /lib/utils/mu-utils.hh
parent677a6d3882ce19c24e7b3494e95332a9aa5983e1 (diff)
utils: add mu_print[ln] for ostreams
Diffstat (limited to 'lib/utils/mu-utils.hh')
-rw-r--r--lib/utils/mu-utils.hh14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/utils/mu-utils.hh b/lib/utils/mu-utils.hh
index 0b7543f..c16c0db 100644
--- a/lib/utils/mu-utils.hh
+++ b/lib/utils/mu-utils.hh
@@ -44,6 +44,7 @@
#include <fmt/format.h>
#include <fmt/core.h>
#include <fmt/chrono.h>
+#include <fmt/ostream.h>
namespace Mu {
@@ -100,7 +101,7 @@ void mu_error(fmt::format_string<T...> frm, T&&... args) noexcept {
}
/*
- * Printing
+ * Printing; add our wrapper functions, one day we might be able to use std::
*/
template<typename...T>
@@ -111,6 +112,7 @@ template<typename...T>
void mu_println(fmt::format_string<T...> frm, T&&... args) noexcept {
fmt::println(frm, std::forward<T>(args)...);
}
+
template<typename...T>
void mu_printerr(fmt::format_string<T...> frm, T&&... args) noexcept {
fmt::print(stderr, frm, std::forward<T>(args)...);
@@ -121,6 +123,16 @@ void mu_printerrln(fmt::format_string<T...> frm, T&&... args) noexcept {
}
+/* stream */
+template<typename...T>
+void mu_print(std::ostream& os, fmt::format_string<T...> frm, T&&... args) noexcept {
+ fmt::print(os, frm, std::forward<T>(args)...);
+}
+template<typename...T>
+void mu_println(std::ostream& os, fmt::format_string<T...> frm, T&&... args) noexcept {
+ fmt::println(os, frm, std::forward<T>(args)...);
+}
+
/*
* Fprmatting
*/