Merge pull request #3275 from lightmare/cleanup-noexcept-and-defaulted
Cleanup defaulted constructors and assignment operators, noexcept specifiers
This commit is contained in:
commit
e75342ac09
15 changed files with 63 additions and 113 deletions
|
@ -90,7 +90,7 @@ private:
|
||||||
using context_type = context<std::map<std::string,std::size_t> >;
|
using context_type = context<std::map<std::string,std::size_t> >;
|
||||||
using context_ptr = std::shared_ptr<context_type>;
|
using context_ptr = std::shared_ptr<context_type>;
|
||||||
|
|
||||||
static const value default_feature_value;
|
static const value default_feature_value{};
|
||||||
|
|
||||||
class MAPNIK_DECL feature_impl : private util::noncopyable
|
class MAPNIK_DECL feature_impl : private util::noncopyable
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,9 +45,6 @@ struct point
|
||||||
point(mapnik::coord<double, 2> const& c)
|
point(mapnik::coord<double, 2> const& c)
|
||||||
: x(c.x), y(c.y) {}
|
: x(c.x), y(c.y) {}
|
||||||
|
|
||||||
point(point const& other) = default;
|
|
||||||
point(point && other) noexcept = default;
|
|
||||||
point & operator=(point const& other) = default;
|
|
||||||
friend inline bool operator== (point<T> const& a, point<T> const& b)
|
friend inline bool operator== (point<T> const& a, point<T> const& b)
|
||||||
{
|
{
|
||||||
return a.x == b.x && a.y == b.y;
|
return a.x == b.x && a.y == b.y;
|
||||||
|
@ -65,12 +62,8 @@ template <typename T>
|
||||||
struct line_string : std::vector<point<T> >
|
struct line_string : std::vector<point<T> >
|
||||||
{
|
{
|
||||||
line_string() = default;
|
line_string() = default;
|
||||||
line_string (std::size_t size)
|
explicit line_string(std::size_t size)
|
||||||
: std::vector<point<T> >(size) {}
|
: std::vector<point<T> >(size) {}
|
||||||
line_string (line_string && other) = default ;
|
|
||||||
line_string& operator=(line_string &&) = default;
|
|
||||||
line_string (line_string const& ) = default;
|
|
||||||
line_string& operator=(line_string const&) = default;
|
|
||||||
inline std::size_t num_points() const { return std::vector<point<T>>::size(); }
|
inline std::size_t num_points() const { return std::vector<point<T>>::size(); }
|
||||||
inline void add_coord(T x, T y) { std::vector<point<T>>::template emplace_back(x,y);}
|
inline void add_coord(T x, T y) { std::vector<point<T>>::template emplace_back(x,y);}
|
||||||
};
|
};
|
||||||
|
@ -79,17 +72,12 @@ template <typename T>
|
||||||
struct linear_ring : line_string<T>
|
struct linear_ring : line_string<T>
|
||||||
{
|
{
|
||||||
linear_ring() = default;
|
linear_ring() = default;
|
||||||
linear_ring(std::size_t size)
|
explicit linear_ring(std::size_t size)
|
||||||
: line_string<T>(size) {}
|
: line_string<T>(size) {}
|
||||||
linear_ring (linear_ring && other) = default ;
|
|
||||||
linear_ring& operator=(linear_ring &&) = default;
|
|
||||||
linear_ring(line_string<T> && other)
|
linear_ring(line_string<T> && other)
|
||||||
: line_string<T>(other) {}
|
: line_string<T>(std::move(other)) {}
|
||||||
linear_ring (linear_ring const& ) = default;
|
|
||||||
linear_ring(line_string<T> const& other)
|
linear_ring(line_string<T> const& other)
|
||||||
: line_string<T>(other) {}
|
: line_string<T>(other) {}
|
||||||
linear_ring& operator=(linear_ring const&) = default;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -102,7 +90,6 @@ struct polygon
|
||||||
using rings_container = InteriorRings<T>;
|
using rings_container = InteriorRings<T>;
|
||||||
rings_container interior_rings;
|
rings_container interior_rings;
|
||||||
|
|
||||||
polygon() = default;
|
|
||||||
inline void set_exterior_ring(linear_ring<T> && ring)
|
inline void set_exterior_ring(linear_ring<T> && ring)
|
||||||
{
|
{
|
||||||
exterior_ring = std::move(ring);
|
exterior_ring = std::move(ring);
|
||||||
|
|
|
@ -54,9 +54,6 @@ template <std::size_t max_size>
|
||||||
struct image_dimensions
|
struct image_dimensions
|
||||||
{
|
{
|
||||||
image_dimensions(int width, int height);
|
image_dimensions(int width, int height);
|
||||||
image_dimensions(image_dimensions const& other) = default;
|
|
||||||
image_dimensions(image_dimensions && other) = default;
|
|
||||||
image_dimensions& operator= (image_dimensions rhs);
|
|
||||||
std::size_t width() const;
|
std::size_t width() const;
|
||||||
std::size_t height() const;
|
std::size_t height() const;
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -55,8 +55,9 @@ struct MAPNIK_DECL image_any : image_base
|
||||||
bool painted = false);
|
bool painted = false);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
image_any(T && _data) noexcept
|
image_any(T && _data)
|
||||||
: image_base(std::move(_data)) {}
|
noexcept(std::is_nothrow_constructible<image_base, T && >::value)
|
||||||
|
: image_base(std::forward<T>(_data)) {}
|
||||||
|
|
||||||
unsigned char const* bytes() const;
|
unsigned char const* bytes() const;
|
||||||
unsigned char* bytes();
|
unsigned char* bytes();
|
||||||
|
|
|
@ -43,14 +43,6 @@ image_dimensions<max_size>::image_dimensions(int width, int height)
|
||||||
if (height < 0 || static_cast<std::size_t>(height) > max_size) throw std::runtime_error("Invalid height for image dimensions requested");
|
if (height < 0 || static_cast<std::size_t>(height) > max_size) throw std::runtime_error("Invalid height for image dimensions requested");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t max_size>
|
|
||||||
image_dimensions<max_size>& image_dimensions<max_size>::operator= (image_dimensions rhs)
|
|
||||||
{
|
|
||||||
std::swap(width_, rhs.width_);
|
|
||||||
std::swap(height_, rhs.height_);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <std::size_t max_size>
|
template <std::size_t max_size>
|
||||||
std::size_t image_dimensions<max_size>::width() const
|
std::size_t image_dimensions<max_size>::width() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,9 +48,6 @@ public:
|
||||||
bool /*initialize*/ = true,
|
bool /*initialize*/ = true,
|
||||||
bool /*premultiplied*/ = false,
|
bool /*premultiplied*/ = false,
|
||||||
bool /*painted*/ = false) {}
|
bool /*painted*/ = false) {}
|
||||||
image(image<null_t> const&) {}
|
|
||||||
image(image<null_t> &&) noexcept {}
|
|
||||||
image<null_t>& operator=(image<null_t>) { return *this; }
|
|
||||||
bool operator==(image<null_t> const&) const { return true; }
|
bool operator==(image<null_t> const&) const { return true; }
|
||||||
bool operator<(image<null_t> const&) const { return false; }
|
bool operator<(image<null_t> const&) const { return false; }
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,7 @@ public:
|
||||||
static constexpr std::size_t pixel_size = sizeof(pixel_type);
|
static constexpr std::size_t pixel_size = sizeof(pixel_type);
|
||||||
|
|
||||||
image_view(std::size_t x, std::size_t y, std::size_t width, std::size_t height, T const& data);
|
image_view(std::size_t x, std::size_t y, std::size_t width, std::size_t height, T const& data);
|
||||||
~image_view();
|
|
||||||
|
|
||||||
image_view(image_view<T> const& rhs);
|
|
||||||
image_view(image_view<T> && other) noexcept;
|
|
||||||
image_view<T>& operator=(image_view<T> rhs) = delete;
|
|
||||||
bool operator==(image_view<T> const& rhs) const;
|
bool operator==(image_view<T> const& rhs) const;
|
||||||
bool operator<(image_view<T> const& rhs) const;
|
bool operator<(image_view<T> const& rhs) const;
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,9 @@ struct MAPNIK_DECL image_view_any : image_view_base
|
||||||
image_view_any() = default;
|
image_view_any() = default;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
image_view_any(T && data) noexcept
|
image_view_any(T && data)
|
||||||
: image_view_base(std::move(data)) {}
|
noexcept(std::is_nothrow_constructible<image_view_base, T && >::value)
|
||||||
|
: image_view_base(std::forward<T>(data)) {}
|
||||||
|
|
||||||
std::size_t width() const;
|
std::size_t width() const;
|
||||||
std::size_t height() const;
|
std::size_t height() const;
|
||||||
|
|
|
@ -42,25 +42,6 @@ image_view<T>::image_view(std::size_t x, std::size_t y, std::size_t width, std::
|
||||||
if (y_ + height_ > data_.height()) height_ = data_.height() - y_;
|
if (y_ + height_ > data_.height()) height_ = data_.height() - y_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
image_view<T>::~image_view() {}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
image_view<T>::image_view(image_view<T> const& rhs)
|
|
||||||
: x_(rhs.x_),
|
|
||||||
y_(rhs.y_),
|
|
||||||
width_(rhs.width_),
|
|
||||||
height_(rhs.height_),
|
|
||||||
data_(rhs.data_) {}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
image_view<T>::image_view(image_view<T> && other) noexcept
|
|
||||||
: x_(std::move(other.x_)),
|
|
||||||
y_(std::move(other.y_)),
|
|
||||||
width_(std::move(other.width_)),
|
|
||||||
height_(std::move(other.height_)),
|
|
||||||
data_(std::move(other.data_)) {}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool image_view<T>::operator==(image_view<T> const& rhs) const
|
bool image_view<T>::operator==(image_view<T> const& rhs) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,18 +58,12 @@ public:
|
||||||
bitmap_data_.set(0xff000000);
|
bitmap_data_.set(0xff000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
marker_rgba8(image_rgba8 const & data)
|
explicit marker_rgba8(image_rgba8 const& data)
|
||||||
: bitmap_data_(data) {}
|
: bitmap_data_(data) {}
|
||||||
|
|
||||||
marker_rgba8(image_rgba8 && data)
|
explicit marker_rgba8(image_rgba8 && data) noexcept
|
||||||
: bitmap_data_(std::move(data)) {}
|
: bitmap_data_(std::move(data)) {}
|
||||||
|
|
||||||
marker_rgba8(marker_rgba8 const& rhs)
|
|
||||||
: bitmap_data_(rhs.bitmap_data_) {}
|
|
||||||
|
|
||||||
marker_rgba8(marker_rgba8 && rhs) noexcept
|
|
||||||
: bitmap_data_(std::move(rhs.bitmap_data_)) {}
|
|
||||||
|
|
||||||
box2d<double> bounding_box() const
|
box2d<double> bounding_box() const
|
||||||
{
|
{
|
||||||
std::size_t _width = bitmap_data_.width();
|
std::size_t _width = bitmap_data_.width();
|
||||||
|
@ -99,17 +93,11 @@ private:
|
||||||
struct marker_svg
|
struct marker_svg
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
marker_svg() { }
|
marker_svg() = default;
|
||||||
|
|
||||||
marker_svg(mapnik::svg_path_ptr data)
|
explicit marker_svg(mapnik::svg_path_ptr data) noexcept
|
||||||
: vector_data_(data) {}
|
: vector_data_(data) {}
|
||||||
|
|
||||||
marker_svg(marker_svg const& rhs)
|
|
||||||
: vector_data_(rhs.vector_data_) {}
|
|
||||||
|
|
||||||
marker_svg(marker_svg && rhs) noexcept
|
|
||||||
: vector_data_(rhs.vector_data_) {}
|
|
||||||
|
|
||||||
inline box2d<double> bounding_box() const
|
inline box2d<double> bounding_box() const
|
||||||
{
|
{
|
||||||
return vector_data_->bounding_box();
|
return vector_data_->bounding_box();
|
||||||
|
@ -140,7 +128,6 @@ private:
|
||||||
|
|
||||||
struct marker_null
|
struct marker_null
|
||||||
{
|
{
|
||||||
marker_null() = default;
|
|
||||||
public:
|
public:
|
||||||
inline box2d<double> bounding_box() const
|
inline box2d<double> bounding_box() const
|
||||||
{
|
{
|
||||||
|
@ -195,8 +182,9 @@ struct marker : marker_base
|
||||||
marker() = default;
|
marker() = default;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
marker(T && _data) noexcept
|
marker(T && _data)
|
||||||
: marker_base(std::move(_data)) {}
|
noexcept(std::is_nothrow_constructible<marker_base, T && >::value)
|
||||||
|
: marker_base(std::forward<T>(_data)) {}
|
||||||
|
|
||||||
double width() const
|
double width() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,8 @@ struct value_holder : value_holder_base
|
||||||
|
|
||||||
// perfect forwarding
|
// perfect forwarding
|
||||||
template <typename T>
|
template <typename T>
|
||||||
value_holder(T && obj) noexcept
|
value_holder(T && obj)
|
||||||
|
noexcept(std::is_nothrow_constructible<value_holder_base, T && >::value)
|
||||||
: value_holder_base(std::forward<T>(obj))
|
: value_holder_base(std::forward<T>(obj))
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,10 +98,8 @@ using value_base_type = util::variant<value_bool,
|
||||||
|
|
||||||
struct strict_value : value_base_type
|
struct strict_value : value_base_type
|
||||||
{
|
{
|
||||||
// default ctor
|
strict_value() = default;
|
||||||
strict_value()
|
|
||||||
: value_base_type() {}
|
|
||||||
// copy ctor
|
|
||||||
strict_value(const char* val)
|
strict_value(const char* val)
|
||||||
: value_base_type(val) {}
|
: value_base_type(val) {}
|
||||||
|
|
||||||
|
@ -109,13 +107,15 @@ struct strict_value : value_base_type
|
||||||
strict_value(T const& obj)
|
strict_value(T const& obj)
|
||||||
: value_base_type(typename detail::mapnik_value_type<T>::type(obj))
|
: value_base_type(typename detail::mapnik_value_type<T>::type(obj))
|
||||||
{}
|
{}
|
||||||
// move ctor
|
|
||||||
template <typename T>
|
|
||||||
strict_value(T && obj) noexcept
|
|
||||||
: value_base_type(std::move(obj)) {}
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
strict_value(T && obj)
|
||||||
|
noexcept(std::is_nothrow_constructible<value_base_type, T && >::value)
|
||||||
|
: value_base_type(std::forward<T>(obj))
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
struct MAPNIK_DECL symbolizer_base
|
struct MAPNIK_DECL symbolizer_base
|
||||||
{
|
{
|
||||||
|
|
|
@ -754,17 +754,36 @@ class value : public value_base
|
||||||
friend const value operator%(value const&,value const&);
|
friend const value operator%(value const&,value const&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
value () noexcept //-- comment out for VC++11
|
value() = default;
|
||||||
: value_base(value_null()) {}
|
|
||||||
|
|
||||||
template <typename T>
|
// conversion from type T is done via a temporary of type U, which
|
||||||
value ( T const& val)
|
// is determined by mapnik_value_type;
|
||||||
: value_base(typename detail::mapnik_value_type<T>::type(val)) {}
|
// enable_if< decay<T> != value > is necessary to avoid ill-formed
|
||||||
|
// recursion in noexcept specifier; and it also prevents using this
|
||||||
|
// constructor where implicitly-declared copy/move should be used
|
||||||
|
// (e.g. value(value&))
|
||||||
|
template <typename T,
|
||||||
|
typename U = typename std::enable_if<
|
||||||
|
!detail::is_same_decay<T, value>::value,
|
||||||
|
detail::mapnik_value_type_decay<T>
|
||||||
|
>::type::type>
|
||||||
|
value(T && val)
|
||||||
|
noexcept(noexcept(U(std::forward<T>(val))) &&
|
||||||
|
std::is_nothrow_constructible<value_base, U && >::value)
|
||||||
|
: value_base(U(std::forward<T>(val))) {}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T,
|
||||||
value ( T && val)
|
typename U = typename std::enable_if<
|
||||||
noexcept(std::is_nothrow_move_constructible<typename std::remove_const<T>::type>::value)
|
!detail::is_same_decay<T, value>::value,
|
||||||
: value_base(std::move(typename detail::mapnik_value_type<T>::type(val))) {}
|
detail::mapnik_value_type_decay<T>
|
||||||
|
>::type::type>
|
||||||
|
value& operator=(T && val)
|
||||||
|
noexcept(noexcept(U(std::forward<T>(val))) &&
|
||||||
|
std::is_nothrow_assignable<value_base, U && >::value)
|
||||||
|
{
|
||||||
|
value_base::operator=(U(std::forward<T>(val)));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(value const& other) const
|
bool operator==(value const& other) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -227,6 +227,13 @@ struct mapnik_value_type<T, typename std::enable_if<detail::is_value_unicode_str
|
||||||
using type = mapnik::value_unicode_string const&;
|
using type = mapnik::value_unicode_string const&;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using mapnik_value_type_decay = mapnik_value_type<typename std::decay<T>::type>;
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
using is_same_decay = std::is_same<typename std::decay<T>::type,
|
||||||
|
typename std::decay<U>::type>;
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
} // namespace mapnik
|
} // namespace mapnik
|
||||||
|
|
|
@ -61,29 +61,12 @@ struct vertex<T,2>
|
||||||
vertex(coord_type x_,coord_type y_,unsigned cmd_)
|
vertex(coord_type x_,coord_type y_,unsigned cmd_)
|
||||||
: x(x_),y(y_),cmd(cmd_) {}
|
: x(x_),y(y_),cmd(cmd_) {}
|
||||||
|
|
||||||
vertex(vertex<T,2> && rhs) noexcept
|
|
||||||
: x(std::move(rhs.x)),
|
|
||||||
y(std::move(rhs.y)),
|
|
||||||
cmd(std::move(rhs.cmd)) {}
|
|
||||||
|
|
||||||
vertex(vertex<T,2> const& rhs)
|
|
||||||
: x(rhs.x),
|
|
||||||
y(rhs.y),
|
|
||||||
cmd(rhs.cmd) {}
|
|
||||||
|
|
||||||
template <typename T2>
|
template <typename T2>
|
||||||
vertex(vertex<T2,2> const& rhs)
|
vertex(vertex<T2,2> const& rhs)
|
||||||
: x(coord_type(rhs.x)),
|
: x(coord_type(rhs.x)),
|
||||||
y(coord_type(rhs.y)),
|
y(coord_type(rhs.y)),
|
||||||
cmd(rhs.cmd) {}
|
cmd(rhs.cmd) {}
|
||||||
|
|
||||||
|
|
||||||
vertex<T,2>& operator=(vertex<T,2> rhs)
|
|
||||||
{
|
|
||||||
swap(rhs);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T2>
|
template <typename T2>
|
||||||
vertex<T,2>& operator=(vertex<T2,2> const& rhs)
|
vertex<T,2>& operator=(vertex<T2,2> const& rhs)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue