diff options
author | bubnikv <bubnikv@gmail.com> | 2017-02-15 13:03:19 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2017-02-15 13:03:19 +0300 |
commit | 90028e47e9c6bb3f5eb61dc064c611b038f55c79 (patch) | |
tree | c10ac58956e3f93779b2b9e6d8c601bc0326c0a1 | |
parent | f5e4026aeee5ae80d2084dd67801eb6956a2f350 (diff) |
Added the append templates for std::vector
-rw-r--r-- | xs/src/libslic3r/libslic3r.h | 24 |
1 files changed, 24 insertions, 0 deletions
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 <stdint.h> #include <stdarg.h> #include <vector> +#include <iterator> +#include <utility> #include <boost/thread.hpp> #define SLIC3R_FORK_NAME "Slic3r Prusa Edition" @@ -137,6 +139,28 @@ parallelize(T start, T end, boost::function<void(T)> func, parallelize(queue, func, threads_count); } +template <typename T> +void append(std::vector<T>& dest, const std::vector<T>& src) +{ + if (dest.empty()) + dest = src; + else + dest.insert(std::end(dest), std::cbegin(src), std::cend(src)); +} + +template <typename T> +void append(std::vector<T>& dest, std::vector<T>&& 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 |