Xped
Loading...
Searching...
No Matches
JoinArray.hpp
Go to the documentation of this file.
1// code from github: https://gist.github.com/klemens-morgenstern/b75599292667a4f53007
2// klemens-morgenstern
3
4#ifndef XPED_JOINARRAY_HPP_
5#define XPED_JOINARRAY_HPP_
6
7namespace Xped {
8
9namespace detail {
10template <std::size_t... Size>
12{};
13
14template <std::size_t Prepend, typename T>
16{};
17
18template <std::size_t Prepend, std::size_t... Sizes>
19struct appender<Prepend, num_tuple<Sizes...>>
20{
21 using type = num_tuple<Prepend, Sizes...>;
22};
23
24template <std::size_t Size, std::size_t Counter = 0>
26{
28};
29
30template <std::size_t Size>
31struct counter_tuple<Size, Size>
32{
34};
35
36} // namespace detail
37
38namespace util {
39
40template<typename T, std::size_t LL, std::size_t RL, std::size_t ... LLs, std::size_t ... RLs>
41constexpr std::array<T, LL+RL> join(const std::array<T, LL> rhs, const std::array<T, RL> lhs, detail::num_tuple<LLs...>, detail::num_tuple<RLs...>)
42{
43 return {rhs[LLs]..., lhs[RLs]... };
44};
45
46
47template<typename T, std::size_t LL, std::size_t RL>
48constexpr std::array<T, LL+RL> join(std::array<T, LL> rhs, std::array<T, RL> lhs)
49{
50 //using l_t = typename detail::counter_tuple<LL>::type;
51 return join(rhs, lhs, typename detail::counter_tuple<LL>::type(), typename detail::counter_tuple<RL>::type());
52}
53
54} // namespace util
55
56} // namespace Xped
57#endif
constexpr std::array< T, LL+RL > join(const std::array< T, LL > rhs, const std::array< T, RL > lhs, detail::num_tuple< LLs... >, detail::num_tuple< RLs... >)
Definition: JoinArray.hpp:41
Definition: bench.cpp:62
Definition: JoinArray.hpp:16
Definition: JoinArray.hpp:26
typename appender< Counter, typename counter_tuple< Size, Counter+1 >::type >::type type
Definition: JoinArray.hpp:27
Definition: JoinArray.hpp:12