From 2bf472988bd6ba1cdb2b5339a29e75bc92720b20 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 19 Dec 2019 09:27:30 +0100 Subject: [PATCH] We can now use std::exchange() as we switched to C++17 --- src/libslic3r/ElephantFootCompensation.cpp | 8 ++++---- src/libslic3r/Utils.hpp | 8 -------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/ElephantFootCompensation.cpp b/src/libslic3r/ElephantFootCompensation.cpp index 69a20b5ec..2694b5e8a 100644 --- a/src/libslic3r/ElephantFootCompensation.cpp +++ b/src/libslic3r/ElephantFootCompensation.cpp @@ -472,7 +472,7 @@ static inline void smooth_compensation_banded(const Points &contour, float band, float l2 = (pthis - pprev).squaredNorm(); if (l2 < dist_min2) { float l = sqrt(l2); - int jprev = exchange(j, prev_idx_modulo(j, contour)); + int jprev = std::exchange(j, prev_idx_modulo(j, contour)); while (j != i) { const Vec2f pp = contour[j].cast(); const float lthis = (pp - pprev).norm(); @@ -487,7 +487,7 @@ static inline void smooth_compensation_banded(const Points &contour, float band, prev = use_min ? std::min(prev, compensation[j]) : compensation[j]; pprev = pp; l = lnext; - jprev = exchange(j, prev_idx_modulo(j, contour)); + jprev = std::exchange(j, prev_idx_modulo(j, contour)); } } @@ -497,7 +497,7 @@ static inline void smooth_compensation_banded(const Points &contour, float band, l2 = (pprev - pthis).squaredNorm(); if (l2 < dist_min2) { float l = sqrt(l2); - int jprev = exchange(j, next_idx_modulo(j, contour)); + int jprev = std::exchange(j, next_idx_modulo(j, contour)); while (j != i) { const Vec2f pp = contour[j].cast(); const float lthis = (pp - pprev).norm(); @@ -512,7 +512,7 @@ static inline void smooth_compensation_banded(const Points &contour, float band, next = use_min ? std::min(next, compensation[j]) : compensation[j]; pprev = pp; l = lnext; - jprev = exchange(j, next_idx_modulo(j, contour)); + jprev = std::exchange(j, next_idx_modulo(j, contour)); } } diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index e5fae485a..f825f65e5 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -217,14 +217,6 @@ inline typename CONTAINER_TYPE::value_type& next_value_modulo(typename CONTAINER return container[next_idx_modulo(idx, container.size())]; } -template -inline T exchange(T& obj, U&& new_value) -{ - T old_value = std::move(obj); - obj = std::forward(new_value); - return old_value; -} - extern std::string xml_escape(std::string text);