Add geom::concat
This commit is contained in:
parent
95dc09d7a3
commit
2e2df09790
1 changed files with 26 additions and 0 deletions
26
libs/geom/include/psemek/geom/concat.hpp
Normal file
26
libs/geom/include/psemek/geom/concat.hpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/geom/vector.hpp>
|
||||
|
||||
namespace psemek::geom
|
||||
{
|
||||
|
||||
template <typename T, std::size_t ... Ns>
|
||||
auto concat(vector<T, Ns> const & ... vs)
|
||||
{
|
||||
vector<T, (Ns + ...)> result;
|
||||
|
||||
std::size_t i = 0;
|
||||
|
||||
auto apply = [&]<std::size_t N>(vector<T, N> const & v)
|
||||
{
|
||||
for (std::size_t j = 0; j < N;)
|
||||
result[i++] = v[j++];
|
||||
};
|
||||
|
||||
(apply(vs), ...);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue