]> git.tdb.fi Git - libs/core.git/blobdiff - source/strings/format.cpp
Add move semantics to Variant
[libs/core.git] / source / strings / format.cpp
index 1b8b4650a9efc852e2ab42268c775d7f5cb858f1..42926e158d593a8a5d84ffb88dfcdddce26a80d5 100644 (file)
@@ -11,6 +11,23 @@ Formatter::Formatter(const string &f):
        advance();
 }
 
+Formatter::Formatter(const Formatter &other):
+       fmt(other.fmt),
+       pos(fmt.begin()+(other.pos-other.fmt.begin())),
+       result(other.result)
+{ }
+
+Formatter &Formatter::operator=(const Formatter &other)
+{
+       if(&other==this)
+               return *this;
+
+       fmt = other.fmt;
+       pos = fmt.begin()+(other.pos-other.fmt.begin());
+       result = other.result;
+       return *this;
+}
+
 const string &Formatter::str() const
 {
        if(pos!=fmt.end())
@@ -41,7 +58,7 @@ Fmt Formatter::get_conversion()
        if(pos==fmt.end())
                throw format_error("Too many arguments for format");
 
-       string::iterator i = pos;
+       auto i = pos;
        for(; i!=fmt.end(); ++i)
                if(isalpha(*i))
                        break;