#ifndef RFL_INTERNAL_TO_STD_ARRAY_HPP_ #define RFL_INTERNAL_TO_STD_ARRAY_HPP_ #include #include #include namespace rfl::internal { template struct StdArrayType { using Type = T; }; template struct StdArrayType { using Type = std::array>::Type, _n>; using ValueType = std::remove_cvref_t; constexpr static size_t size = _n; }; template using to_std_array_t = StdArrayType::Type; template auto to_std_array(T&& _t) { using Type = std::remove_cvref_t; if constexpr (std::is_array_v) { constexpr size_t n = StdArrayType::size; const auto fct = [&](std::index_sequence<_i...>) { return to_std_array_t( { to_std_array(std::forward::ValueType>(_t[_i]))... } ); }; return fct(std::make_index_sequence()); } else { return std::forward(_t); } } template auto to_std_array(const T& _t) { using Type = std::remove_cvref_t; if constexpr (std::is_array_v) { constexpr size_t n = StdArrayType::size; const auto fct = [&](std::index_sequence<_i...>) { return to_std_array_t({ to_std_array(_t[_i])... }); }; return fct(std::make_index_sequence()); } else { return _t; } } } // namespace rfl::internal #endif