+ 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:
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;

View file

@ -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;
}