aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-12-05 17:48:16 +0100
committerEelco Dolstra <edolstra@gmail.com>2019-12-05 19:58:49 +0100
commit603b2f583c3be45481d2d0e45e8ee8bfa9cfbfcf (patch)
tree51c4c7671d107f0eb49f1b52e11dfa58d2940df5 /src/libutil
parent334b8f8af1c47970e6cdf3ca6f45dfb8cd8e7938 (diff)
Revert "Make fmt() non-recursive"
This reverts commit 2b761d5f50b7dc17dc55c31980c2253c37b3c920. Also *really* make fmt() take arguments by reference.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/logging.hh2
-rw-r--r--src/libutil/types.hh12
2 files changed, 12 insertions, 2 deletions
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh
index 3fbd75562..beb5e6b64 100644
--- a/src/libutil/logging.hh
+++ b/src/libutil/logging.hh
@@ -161,7 +161,7 @@ template<typename... Args>
inline void warn(const std::string & fs, const Args & ... args)
{
boost::format f(fs);
- nop{boost::io::detail::feed(f, args)...};
+ formatHelper(f, args...);
logger->warn(f.str());
}
diff --git a/src/libutil/types.hh b/src/libutil/types.hh
index 4a6be28a2..5d3e76421 100644
--- a/src/libutil/types.hh
+++ b/src/libutil/types.hh
@@ -51,6 +51,16 @@ struct FormatOrString
... a_n’. However, ‘fmt(s)’ is equivalent to ‘s’ (so no %-expansion
takes place). */
+inline void formatHelper(boost::format & f)
+{
+}
+
+template<typename T, typename... Args>
+inline void formatHelper(boost::format & f, const T & x, const Args & ... args)
+{
+ formatHelper(f % x, args...);
+}
+
inline std::string fmt(const std::string & s)
{
return s;
@@ -71,7 +81,7 @@ inline std::string fmt(const std::string & fs, const Args & ... args)
{
boost::format f(fs);
f.exceptions(boost::io::all_error_bits ^ boost::io::too_many_args_bit);
- nop{boost::io::detail::feed(f, args)...};
+ formatHelper(f, args...);
return f.str();
}