mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Make fmt() non-recursive
This commit is contained in:
parent
0124d118ef
commit
2b761d5f50
2 changed files with 7 additions and 12 deletions
|
@ -88,7 +88,7 @@ template<typename... Args>
|
|||
inline void warn(const std::string & fs, Args... args)
|
||||
{
|
||||
boost::format f(fs);
|
||||
formatHelper(f, args...);
|
||||
nop{boost::io::detail::feed(f, args)...};
|
||||
logger->warn(f.str());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,11 @@ using std::vector;
|
|||
using boost::format;
|
||||
|
||||
|
||||
/* A variadic template that does nothing. Useful to call a function
|
||||
for all variadic arguments but ignoring the result. */
|
||||
struct nop { template<typename... T> nop(T...) {} };
|
||||
|
||||
|
||||
struct FormatOrString
|
||||
{
|
||||
string s;
|
||||
|
@ -46,16 +51,6 @@ 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, T x, Args... args)
|
||||
{
|
||||
formatHelper(f % x, args...);
|
||||
}
|
||||
|
||||
inline std::string fmt(const std::string & s)
|
||||
{
|
||||
return s;
|
||||
|
@ -75,7 +70,7 @@ template<typename... Args>
|
|||
inline std::string fmt(const std::string & fs, Args... args)
|
||||
{
|
||||
boost::format f(fs);
|
||||
formatHelper(f, args...);
|
||||
nop{boost::io::detail::feed(f, args)...};
|
||||
return f.str();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue