+ implement assignment operator in terms of a copy construction and a swap.
This commit is contained in:
parent
1a813f8af2
commit
c1a9b60b50
2 changed files with 4 additions and 7 deletions
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue