From c1a9b60b50b74e21ea67e92c13c52d4b2d930ec2 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 17 Jul 2013 10:44:42 +0100 Subject: [PATCH] + implement assignment operator in terms of a copy construction and a swap. --- include/mapnik/font_set.hpp | 2 +- src/font_set.cpp | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/mapnik/font_set.hpp b/include/mapnik/font_set.hpp index 426d60b06..a6de922be 100644 --- a/include/mapnik/font_set.hpp +++ b/include/mapnik/font_set.hpp @@ -37,7 +37,7 @@ class MAPNIK_DECL font_set public: font_set(std::string const& name); font_set(font_set const& rhs); - font_set& operator=(font_set const& rhs); + font_set& operator=(font_set rhs); unsigned size() const; void set_name(std::string const& name); std::string const& get_name() const; diff --git a/src/font_set.cpp b/src/font_set.cpp index fdd04229a..f397112ed 100644 --- a/src/font_set.cpp +++ b/src/font_set.cpp @@ -36,13 +36,10 @@ font_set::font_set(font_set const& rhs) : name_(rhs.name_), face_names_(rhs.face_names_) {} -font_set& font_set::operator=(font_set const& other) +font_set& font_set::operator=(font_set other) { - if (this == &other) - return *this; - name_ = other.name_; - face_names_ = other.face_names_; - + std::swap(name_,other.name_); + std::swap(face_names_,other.face_names_); return *this; }