operator= using std::swap §

This commit is contained in:
artemp 2014-01-28 10:57:26 +00:00
parent 6f81c88f9a
commit 322b378971
4 changed files with 6 additions and 31 deletions

View file

@ -65,7 +65,7 @@ private:
public:
feature_type_style();
feature_type_style(feature_type_style const& rhs);
feature_type_style& operator=(feature_type_style const& rhs);
feature_type_style& operator=(feature_type_style rhs);
void add_rule(rule const& rule);
rules const& get_rules() const;

View file

@ -48,7 +48,7 @@ public:
std::string const& srs=MAPNIK_LONGLAT_PROJ);
layer(layer const& l);
layer& operator=(layer const& rhs);
layer& operator=(layer rhs) noexcept;
bool operator==(layer const& other) const;
/*!
@ -199,7 +199,6 @@ public:
void reset_buffer_size();
~layer();
private:
void swap(layer& other);
std::string name_;
std::string srs_;

View file

@ -55,14 +55,9 @@ feature_type_style::feature_type_style(feature_type_style const& rhs)
opacity_(rhs.opacity_)
{}
feature_type_style& feature_type_style::operator=(feature_type_style const& other)
feature_type_style& feature_type_style::operator=(feature_type_style rhs)
{
if (this == &other) return *this;
rules_ = other.rules_;
filters_= other.filters_;
direct_filters_ = other.direct_filters_;
comp_op_ = other.comp_op_;
opacity_ = other.opacity_;
std::swap(*this, rhs);
return *this;
}

View file

@ -57,10 +57,9 @@ layer::layer(const layer& rhs)
buffer_size_(rhs.buffer_size_),
maximum_extent_(rhs.maximum_extent_) {}
layer& layer::operator=(layer const& rhs)
layer& layer::operator=(layer rhs) noexcept
{
layer tmp(rhs);
swap(tmp);
std::swap(*this, rhs);
return *this;
}
@ -69,24 +68,6 @@ bool layer::operator==(layer const& other) const
return (this == &other);
}
void layer::swap(layer& rhs)
{
using std::swap;
swap(name_, rhs.name_);
swap(srs_, rhs.srs_);
swap(min_zoom_, rhs.min_zoom_);
swap(max_zoom_, rhs.max_zoom_);
swap(active_, rhs.active_);
swap(queryable_, rhs.queryable_);
swap(clear_label_cache_, rhs.clear_label_cache_);
swap(cache_features_, rhs.cache_features_);
swap(group_by_, rhs.group_by_);
swap(styles_, rhs.styles_);
swap(ds_, rhs.ds_);
swap(buffer_size_, rhs.buffer_size_);
swap(maximum_extent_, rhs.maximum_extent_);
}
layer::~layer() {}
void layer::set_name( std::string const& name)