]> git.tdb.fi Git - libs/core.git/blobdiff - source/strings/format.h
Add move semantics to Variant
[libs/core.git] / source / strings / format.h
index 7bd8264f2407495d4c306501e6979703eb4740e5..7969ef3930c01979e1948d63b97dccd9b6f2a026 100644 (file)
@@ -2,6 +2,7 @@
 #define MSP_STRINGS_FORMAT_H_
 
 #include <string>
+#include <msp/core/mspcore_api.h>
 #include "lexicalcast.h"
 
 namespace Msp {
@@ -9,7 +10,7 @@ namespace Msp {
 /**
 Printf-like string formatter class.
 */
-class Formatter
+class MSPCORE_API Formatter
 {
 private:
        std::string fmt;
@@ -18,6 +19,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,13 +32,11 @@ public:
                return *this;
        }
 
-#if __cplusplus>=201103L
        template<typename T, typename... Tail>
        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. */
@@ -55,35 +56,12 @@ private:
 inline Formatter format(const std::string &f)
 { return Formatter(f); }
 
-#if __cplusplus >= 201103L
 template<typename... Args>
 inline std::string format(const std::string &f, const Args &... args)
 {
        return Formatter(f)(args...).str();
 }
 
-#else
-template<typename A1>
-inline std::string format(const std::string &f, const A1 &a1)
-{ return Formatter(f)(a1).str(); }
-
-template<typename A1, typename A2>
-inline std::string format(const std::string &f, const A1 &a1, const A2 &a2)
-{ return Formatter(f)(a1)(a2).str(); }
-
-template<typename A1, typename A2, typename A3>
-inline std::string format(const std::string &f, const A1 &a1, const A2 &a2, const A3 &a3)
-{ return Formatter(f)(a1)(a2)(a3).str(); }
-
-template<typename A1, typename A2, typename A3, typename A4>
-inline std::string format(const std::string &f, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
-{ return Formatter(f)(a1)(a2)(a3)(a4).str(); }
-
-template<typename A1, typename A2, typename A3, typename A4, typename A5>
-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
 
 #endif