+ implement assignment operator in terms of a copy construction and a swap.

This commit is contained in:
artemp 2013-07-17 10:44:42 +01:00
parent 1a813f8af2
commit c1a9b60b50
2 changed files with 4 additions and 7 deletions

View file

@ -37,7 +37,7 @@ class MAPNIK_DECL font_set
public: public:
font_set(std::string const& name); font_set(std::string const& name);
font_set(font_set const& rhs); font_set(font_set const& rhs);
font_set& operator=(font_set const& rhs); font_set& operator=(font_set rhs);
unsigned size() const; unsigned size() const;
void set_name(std::string const& name); void set_name(std::string const& name);
std::string const& get_name() const; std::string const& get_name() const;

View file

@ -36,13 +36,10 @@ font_set::font_set(font_set const& rhs)
: name_(rhs.name_), : name_(rhs.name_),
face_names_(rhs.face_names_) {} 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) std::swap(name_,other.name_);
return *this; std::swap(face_names_,other.face_names_);
name_ = other.name_;
face_names_ = other.face_names_;
return *this; return *this;
} }