Skip to content

Commit

Permalink
Fixing some missing throw statements.
Browse files Browse the repository at this point in the history
Adding noexcept to move constructors / operators.
  • Loading branch information
bubnikv committed Jan 13, 2020
1 parent 9a3901e commit 79d7a01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/libslic3r/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class ConfigOptionFloatsTempl : public ConfigOptionVector<double>
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;
Expand All @@ -525,9 +525,9 @@ class ConfigOptionFloatsTempl : public ConfigOptionVector<double>
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<double> &v1, const std::vector<double> &v2) {
if (NULLABLE) {
Expand Down Expand Up @@ -646,7 +646,7 @@ class ConfigOptionIntsTempl : public ConfigOptionVector<int>
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;
Expand All @@ -663,7 +663,7 @@ class ConfigOptionIntsTempl : public ConfigOptionVector<int>
if (NULLABLE)
ss << "nil";
else
std::runtime_error("Serializing NaN");
throw std::runtime_error("Serializing NaN");
} else
ss << v;
}
Expand Down Expand Up @@ -1126,7 +1126,7 @@ class ConfigOptionBoolsTempl : public ConfigOptionVector<unsigned char>
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);
}
Expand All @@ -1139,7 +1139,7 @@ class ConfigOptionBoolsTempl : public ConfigOptionVector<unsigned char>
if (NULLABLE)
ss << "nil";
else
std::runtime_error("Serializing NaN");
throw std::runtime_error("Serializing NaN");
} else
ss << (v ? "1" : "0");
}
Expand Down Expand Up @@ -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(); }
Expand All @@ -1656,7 +1656,7 @@ class DynamicConfig : public virtual ConfigBase

// 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();
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/ExPolygon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand All @@ -32,7 +32,7 @@ class ExPolygon
ExPolygon(std::initializer_list<Point> contour, std::initializer_list<Point> 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;
Expand Down

0 comments on commit 79d7a01

Please sign in to comment.