X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstrings%2Fformat.h;h=ea5d5b070090c770671fc7821435a520e333321c;hb=20c897ece781e18ba54c41fd68e232ce566a938d;hp=65d10dffa585bb6e272db7d1d20a71a07b6a0a42;hpb=42ff7c629b2aa7411963bdcc2259a06b1d1de6d3;p=libs%2Fcore.git diff --git a/source/strings/format.h b/source/strings/format.h index 65d10df..ea5d5b0 100644 --- a/source/strings/format.h +++ b/source/strings/format.h @@ -18,6 +18,8 @@ private: public: Formatter(const std::string &); + Formatter(const Formatter &); + Formatter &operator=(const Formatter &); /** Extracts the next conversion from the format string and formats the given value with it. Will throw if no more conversions are found. */ @@ -29,6 +31,14 @@ public: return *this; } +#if __cplusplus>=201103L + template + Formatter &operator()(const T &a, const Tail &... tail) + { + return (*this)(a)(tail...); + } +#endif + /** Returns the result of the formatting operation. Will throw if not enough values have been fed to the formatter. */ const std::string &str() const; @@ -47,6 +57,14 @@ private: inline Formatter format(const std::string &f) { return Formatter(f); } +#if __cplusplus >= 201103L +template +inline std::string format(const std::string &f, const Args &... args) +{ + return Formatter(f)(args...).str(); +} + +#else template inline std::string format(const std::string &f, const A1 &a1) { return Formatter(f)(a1).str(); } @@ -66,6 +84,7 @@ inline std::string format(const std::string &f, const A1 &a1, const A2 &a2, cons template inline std::string format(const std::string &f, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return Formatter(f)(a1)(a2)(a3)(a4)(a5).str(); } +#endif } // namespace Msp