Fix the build on GCC 4.2.1 from MacOS X.

This commit is contained in:
Victor Zverovich 2012-12-14 19:01:48 -08:00
parent 6e1d142a56
commit 6861ac4718

View File

@ -303,6 +303,9 @@ class Formatter {
std::string str() const { return std::string(&buffer_[0], buffer_.size()); } std::string str() const { return std::string(&buffer_[0], buffer_.size()); }
}; };
template <typename Action>
class ActiveFormatter;
namespace internal { namespace internal {
// This is a transient object that normally exists only as a temporary // This is a transient object that normally exists only as a temporary
@ -315,18 +318,21 @@ class ArgInserter {
friend class format::Formatter; friend class format::Formatter;
// Do not implement.
void operator=(const ArgInserter& other);
protected: protected:
explicit ArgInserter(Formatter *f = 0) : formatter_(f) {} explicit ArgInserter(Formatter *f = 0) : formatter_(f) {}
ArgInserter(ArgInserter& other) void Init(Formatter &f, const char *format) {
: formatter_(other.formatter_) { const ArgInserter &other = f(format);
formatter_ = other.formatter_;
other.formatter_ = 0; other.formatter_ = 0;
} }
ArgInserter& operator=(const ArgInserter& other) { ArgInserter(const ArgInserter& other)
formatter_ = other.formatter_; : formatter_(other.formatter_) {
other.formatter_ = 0; other.formatter_ = 0;
return *this;
} }
const Formatter *Format() const { const Formatter *Format() const {
@ -341,7 +347,7 @@ class ArgInserter {
Formatter *formatter() const { return formatter_; } Formatter *formatter() const { return formatter_; }
const char *format() const { return formatter_->format_; } const char *format() const { return formatter_->format_; }
void ResetFormatter() { formatter_ = 0; } void ResetFormatter() const { formatter_ = 0; }
public: public:
~ArgInserter() { ~ArgInserter() {
@ -406,7 +412,7 @@ class ActiveFormatter : public internal::ArgInserter {
// for examples of action classes. // for examples of action classes.
explicit ActiveFormatter(const char *format, Action a = Action()) explicit ActiveFormatter(const char *format, Action a = Action())
: action_(a) { : action_(a) {
ArgInserter::operator=(formatter_(format)); Init(formatter_, format);
} }
// Creates an active formatter with the same format string and action // Creates an active formatter with the same format string and action
@ -414,9 +420,9 @@ class ActiveFormatter : public internal::ArgInserter {
// destructor. Note that the buffer content is not copied because the // destructor. Note that the buffer content is not copied because the
// the buffer in ActiveFormatter is populated when all the arguments // the buffer in ActiveFormatter is populated when all the arguments
// are provided. // are provided.
ActiveFormatter(ActiveFormatter &other) ActiveFormatter(const ActiveFormatter &other)
: ArgInserter(0), action_(other.action_) { : ArgInserter(0), action_(other.action_) {
ArgInserter::operator=(formatter_(other.format())); Init(formatter_, other.format());
other.ResetFormatter(); other.ResetFormatter();
} }