From 90028e47e9c6bb3f5eb61dc064c611b038f55c79 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 15 Feb 2017 11:03:19 +0100 Subject: [PATCH] Added the append templates for std::vector --- xs/src/libslic3r/libslic3r.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/xs/src/libslic3r/libslic3r.h b/xs/src/libslic3r/libslic3r.h index d2a3c7c86..d36e79ab3 100644 --- a/xs/src/libslic3r/libslic3r.h +++ b/xs/src/libslic3r/libslic3r.h @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #define SLIC3R_FORK_NAME "Slic3r Prusa Edition" @@ -137,6 +139,28 @@ parallelize(T start, T end, boost::function func, parallelize(queue, func, threads_count); } +template +void append(std::vector& dest, const std::vector& src) +{ + if (dest.empty()) + dest = src; + else + dest.insert(std::end(dest), std::cbegin(src), std::cend(src)); +} + +template +void append(std::vector& dest, std::vector&& src) +{ + if (dest.empty()) + dest = std::move(src); + else + dest.insert(std::end(dest), + std::make_move_iterator(std::begin(src)), + std::make_move_iterator(std::end(src))); + src.clear(); + src.shrink_to_fit(); +} + } // namespace Slic3r #endif