mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
29 lines
690 B
C++
29 lines
690 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
/// Appends a specified vector with elements of another vector.
|
|
template <typename T>
|
|
void insertAtEnd(std::vector<T> & dest, const std::vector<T> & src)
|
|
{
|
|
if (src.empty())
|
|
return;
|
|
dest.reserve(dest.size() + src.size());
|
|
dest.insert(dest.end(), src.begin(), src.end());
|
|
}
|
|
|
|
template <typename T>
|
|
void insertAtEnd(std::vector<T> & dest, std::vector<T> && src)
|
|
{
|
|
if (src.empty())
|
|
return;
|
|
if (dest.empty())
|
|
{
|
|
dest.swap(src);
|
|
return;
|
|
}
|
|
dest.reserve(dest.size() + src.size());
|
|
dest.insert(dest.end(), std::make_move_iterator(src.begin()), std::make_move_iterator(src.end()));
|
|
src.clear();
|
|
}
|