We can now use std::exchange() as we switched to C++17
This commit is contained in:
parent
71ff0f9cae
commit
2bf472988b
2 changed files with 4 additions and 12 deletions
|
@ -472,7 +472,7 @@ static inline void smooth_compensation_banded(const Points &contour, float band,
|
||||||
float l2 = (pthis - pprev).squaredNorm();
|
float l2 = (pthis - pprev).squaredNorm();
|
||||||
if (l2 < dist_min2) {
|
if (l2 < dist_min2) {
|
||||||
float l = sqrt(l2);
|
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) {
|
while (j != i) {
|
||||||
const Vec2f pp = contour[j].cast<float>();
|
const Vec2f pp = contour[j].cast<float>();
|
||||||
const float lthis = (pp - pprev).norm();
|
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];
|
prev = use_min ? std::min(prev, compensation[j]) : compensation[j];
|
||||||
pprev = pp;
|
pprev = pp;
|
||||||
l = lnext;
|
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();
|
l2 = (pprev - pthis).squaredNorm();
|
||||||
if (l2 < dist_min2) {
|
if (l2 < dist_min2) {
|
||||||
float l = sqrt(l2);
|
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) {
|
while (j != i) {
|
||||||
const Vec2f pp = contour[j].cast<float>();
|
const Vec2f pp = contour[j].cast<float>();
|
||||||
const float lthis = (pp - pprev).norm();
|
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];
|
next = use_min ? std::min(next, compensation[j]) : compensation[j];
|
||||||
pprev = pp;
|
pprev = pp;
|
||||||
l = lnext;
|
l = lnext;
|
||||||
jprev = exchange(j, next_idx_modulo(j, contour));
|
jprev = std::exchange(j, next_idx_modulo(j, contour));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,14 +217,6 @@ inline typename CONTAINER_TYPE::value_type& next_value_modulo(typename CONTAINER
|
||||||
return container[next_idx_modulo(idx, container.size())];
|
return container[next_idx_modulo(idx, container.size())];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class U = T>
|
|
||||||
inline T exchange(T& obj, U&& new_value)
|
|
||||||
{
|
|
||||||
T old_value = std::move(obj);
|
|
||||||
obj = std::forward<U>(new_value);
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern std::string xml_escape(std::string text);
|
extern std::string xml_escape(std::string text);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue