mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-31 17:12:56 +00:00
Fixed crashes intruduced recently into G-code generator.
Added a template sort_remove_duplicates.
This commit is contained in:
@@ -100,7 +100,7 @@ inline void append_to(std::vector<T> &dst, const std::vector<T> &src)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void append(std::vector<T>& dest, const std::vector<T>& src)
|
||||
inline void append(std::vector<T>& dest, const std::vector<T>& src)
|
||||
{
|
||||
if (dest.empty())
|
||||
dest = src;
|
||||
@@ -109,7 +109,7 @@ void append(std::vector<T>& dest, const std::vector<T>& src)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void append(std::vector<T>& dest, std::vector<T>&& src)
|
||||
inline void append(std::vector<T>& dest, std::vector<T>&& src)
|
||||
{
|
||||
if (dest.empty())
|
||||
dest = std::move(src);
|
||||
@@ -120,13 +120,20 @@ void append(std::vector<T>& dest, std::vector<T>&& src)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void remove_nulls(std::vector<T*> &vec)
|
||||
inline void remove_nulls(std::vector<T*> &vec)
|
||||
{
|
||||
vec.erase(
|
||||
std::remove_if(vec.begin(), vec.end(), [](const T *ptr) { return ptr == nullptr; }),
|
||||
vec.end());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void sort_remove_duplicates(std::vector<T> &vec)
|
||||
{
|
||||
std::sort(vec.begin(), vec.end());
|
||||
vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
|
||||
}
|
||||
|
||||
// Older compilers do not provide a std::make_unique template. Provide a simple one.
|
||||
template<typename T, typename... Args>
|
||||
inline std::unique_ptr<T> make_unique(Args&&... args) {
|
||||
|
||||
Reference in New Issue
Block a user