Argon 0.1.0
Loading...
Searching...
No Matches
to_array.hpp
Go to the documentation of this file.
1#pragma once
2#include <array>
3#include "argon_for.hpp"
4
7
8namespace argon {
9namespace detail {
10template <class T, std::size_t N, std::size_t... I>
11constexpr std::array<helpers::ArgonFor_t<T>, N> to_array_impl(T (&a)[N], std::index_sequence<I...>) {
12 using argon_type = helpers::ArgonFor_t<T>;
13 return {{argon_type{a[I]}...}};
14}
15
16template <class T, std::size_t N, std::size_t... I>
17constexpr std::array<helpers::ArgonFor_t<T>, N> to_array_impl(T (&&a)[N], std::index_sequence<I...>) {
18 using argon_type = helpers::ArgonFor_t<T>;
19 return {{argon_type{std::move(a[I])}...}};
20}
21} // namespace detail
22
28template <class T, std::size_t N>
29constexpr std::array<helpers::ArgonFor_t<T>, N> to_array(T (&a)[N]) {
30 return detail::to_array_impl(a, std::make_index_sequence<N>{});
31}
32
39template <class T, std::size_t N>
40constexpr std::array<helpers::ArgonFor_t<T>, N> to_array(T (&&a)[N]) {
41 return detail::to_array_impl(std::move(a), std::make_index_sequence<N>{});
42}
43
44} // namespace argon
typename ArgonFor< std::remove_cv_t< T > >::type ArgonFor_t
Helper alias to get the Argon type for a given vector type.
Definition argon_for.hpp:45
constexpr std::array< helpers::ArgonFor_t< T >, N > to_array(T(&a)[N])
Convert a C-style array of vector types to a std::array of Argon types.
Definition to_array.hpp:29