From 79d7a0130f687a3814d5061cafdf8501338909c0 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 13 Jan 2020 17:41:40 +0100 Subject: [PATCH] Fixing some missing throw statements. Adding noexcept to move constructors / operators. --- src/libslic3r/Config.hpp | 18 +++++++++--------- src/libslic3r/ExPolygon.hpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index e7ecc2977..9b04ae026 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -500,7 +500,7 @@ public: if (NULLABLE) this->values.push_back(nil_value()); else - std::runtime_error("Deserializing nil into a non-nullable object"); + throw std::runtime_error("Deserializing nil into a non-nullable object"); } else { std::istringstream iss(item_str); double value; @@ -525,9 +525,9 @@ protected: if (NULLABLE) ss << "nil"; else - std::runtime_error("Serializing NaN"); + throw std::runtime_error("Serializing NaN"); } else - std::runtime_error("Serializing invalid number"); + throw std::runtime_error("Serializing invalid number"); } static bool vectors_equal(const std::vector &v1, const std::vector &v2) { if (NULLABLE) { @@ -646,7 +646,7 @@ public: if (NULLABLE) this->values.push_back(nil_value()); else - std::runtime_error("Deserializing nil into a non-nullable object"); + throw std::runtime_error("Deserializing nil into a non-nullable object"); } else { std::istringstream iss(item_str); int value; @@ -663,7 +663,7 @@ private: if (NULLABLE) ss << "nil"; else - std::runtime_error("Serializing NaN"); + throw std::runtime_error("Serializing NaN"); } else ss << v; } @@ -1126,7 +1126,7 @@ public: if (NULLABLE) this->values.push_back(nil_value()); else - std::runtime_error("Deserializing nil into a non-nullable object"); + throw std::runtime_error("Deserializing nil into a non-nullable object"); } else this->values.push_back(item_str.compare("1") == 0); } @@ -1139,7 +1139,7 @@ protected: if (NULLABLE) ss << "nil"; else - std::runtime_error("Serializing NaN"); + throw std::runtime_error("Serializing NaN"); } else ss << (v ? "1" : "0"); } @@ -1638,7 +1638,7 @@ class DynamicConfig : public virtual ConfigBase public: DynamicConfig() {} DynamicConfig(const DynamicConfig &rhs) { *this = rhs; } - DynamicConfig(DynamicConfig &&rhs) : options(std::move(rhs.options)) { rhs.options.clear(); } + DynamicConfig(DynamicConfig &&rhs) noexcept : options(std::move(rhs.options)) { rhs.options.clear(); } explicit DynamicConfig(const ConfigBase &rhs, const t_config_option_keys &keys); explicit DynamicConfig(const ConfigBase& rhs) : DynamicConfig(rhs, rhs.keys()) {} virtual ~DynamicConfig() override { clear(); } @@ -1656,7 +1656,7 @@ public: // Move a content of one DynamicConfig to another DynamicConfig. // If rhs.def() is not null, then it has to be equal to this->def(). - DynamicConfig& operator=(DynamicConfig &&rhs) + DynamicConfig& operator=(DynamicConfig &&rhs) noexcept { assert(this->def() == nullptr || this->def() == rhs.def()); this->clear(); diff --git a/src/libslic3r/ExPolygon.hpp b/src/libslic3r/ExPolygon.hpp index 4ee8974f4..7c0dfcce5 100644 --- a/src/libslic3r/ExPolygon.hpp +++ b/src/libslic3r/ExPolygon.hpp @@ -19,7 +19,7 @@ class ExPolygon public: ExPolygon() {} ExPolygon(const ExPolygon &other) : contour(other.contour), holes(other.holes) {} - ExPolygon(ExPolygon &&other) : contour(std::move(other.contour)), holes(std::move(other.holes)) {} + ExPolygon(ExPolygon &&other) noexcept : contour(std::move(other.contour)), holes(std::move(other.holes)) {} explicit ExPolygon(const Polygon &contour) : contour(contour) {} explicit ExPolygon(Polygon &&contour) : contour(std::move(contour)) {} explicit ExPolygon(const Points &contour) : contour(contour) {} @@ -32,7 +32,7 @@ public: ExPolygon(std::initializer_list contour, std::initializer_list hole) : contour(contour), holes({ hole }) {} ExPolygon& operator=(const ExPolygon &other) { contour = other.contour; holes = other.holes; return *this; } - ExPolygon& operator=(ExPolygon &&other) { contour = std::move(other.contour); holes = std::move(other.holes); return *this; } + ExPolygon& operator=(ExPolygon &&other) noexcept { contour = std::move(other.contour); holes = std::move(other.holes); return *this; } Polygon contour; Polygons holes;