Added the append templates for std::vector

This commit is contained in:
bubnikv 2017-02-15 11:03:19 +01:00
parent f5e4026aee
commit 90028e47e9

View File

@ -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