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>
11[[gnu::always_inline]] constexpr std::array<helpers::ArgonFor_t<T>, N> to_array_impl(T (&a)[N],
12 std::index_sequence<I...>) {
13 using argon_type = helpers::ArgonFor_t<T>;
14 return {{argon_type{a[I]}...}};
15}
16
17template <class T, std::size_t N, std::size_t... I>
18[[gnu::always_inline]] constexpr std::array<helpers::ArgonFor_t<T>, N> to_array_impl(T (&&a)[N],
19 std::index_sequence<I...>) {
20 using argon_type = helpers::ArgonFor_t<T>;
21 return {{argon_type{std::move(a[I])}...}};
22}
23} // namespace detail
24
30template <class T, std::size_t N>
31[[gnu::always_inline]] constexpr std::array<helpers::ArgonFor_t<T>, N> to_array(T (&a)[N]) {
32 return detail::to_array_impl(a, std::make_index_sequence<N>{});
33}
34
41template <class T, std::size_t N>
42[[gnu::always_inline]] constexpr std::array<helpers::ArgonFor_t<T>, N> to_array(T (&&a)[N]) {
43 return detail::to_array_impl(std::move(a), std::make_index_sequence<N>{});
44}
45
46} // 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:46
A 128-bit SIMD vector wrapping a scalar type, providing arithmetic, logical, and data-movement operat...
Definition argon.hpp:30
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:31