template<int...>
struct S {};
constexpr auto a = std::array{0, 1, 2};
I would like to unpack the elements of a
as template arguments to S
. That is; S<0, 1, 2>
.
A possible C++2a implementation:
template<auto tuple_like, template<auto...> typename Template>
constexpr decltype(auto) unpack()
{
constexpr auto size = std::tuple_size_v<decltype(tuple_like)>;
return []<std::size_t... Is>(std::index_sequence<Is...>) {
return Template<std::get<Is>(tuple_like)...>{};
}(std::make_index_sequence<size>{});
}
using Result = decltype(unpack<a, S>());
Is there an idiomatic way to do this in Boost.Hana?