mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 17:44:23 +00:00
39 lines
945 B
C++
39 lines
945 B
C++
|
#pragma once
|
||
|
|
||
|
#include <utility>
|
||
|
#include <type_traits>
|
||
|
#include <array>
|
||
|
|
||
|
namespace ext
|
||
|
{
|
||
|
|
||
|
namespace detail
|
||
|
{
|
||
|
|
||
|
template<std::size_t size, typename T, std::size_t... indexes>
|
||
|
constexpr auto make_array_n_impl(T && value, std::index_sequence<indexes...>)
|
||
|
{
|
||
|
return std::array<std::decay_t<T>, size>{ (static_cast<void>(indexes), value)..., std::forward<T>(value) };
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
template<typename T>
|
||
|
constexpr auto make_array_n(std::integral_constant<std::size_t, 0>, T &&)
|
||
|
{
|
||
|
return std::array<std::decay_t<T>, 0>{};
|
||
|
}
|
||
|
|
||
|
template<std::size_t size, typename T>
|
||
|
constexpr auto make_array_n(std::integral_constant<std::size_t, size>, T && value)
|
||
|
{
|
||
|
return detail::make_array_n_impl<size>(std::forward<T>(value), std::make_index_sequence<size - 1>{});
|
||
|
}
|
||
|
|
||
|
template<std::size_t size, typename T>
|
||
|
constexpr auto make_array_n(T && value)
|
||
|
{
|
||
|
return make_array_n(std::integral_constant<std::size_t, size>{}, std::forward<T>(value));
|
||
|
}
|
||
|
}
|