diff --git a/sprout/array/array.hpp b/sprout/array/array.hpp index 2f08450b..8da39792 100644 --- a/sprout/array/array.hpp +++ b/sprout/array/array.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,7 @@ #include #include #include +#include #if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION # include #endif @@ -271,19 +273,46 @@ namespace sprout { lhs.swap(rhs); } - namespace detail { - template - inline SPROUT_CONSTEXPR sprout::array::type, N> - to_array_impl(T (& arr)[N], sprout::index_tuple) { - return sprout::array::type, N>{{arr[Indexes]...}}; - } - } // namespace detail // // to_array // template + inline SPROUT_CONSTEXPR sprout::array + to_array(sprout::array const& arr) + SPROUT_NOEXCEPT_IF(sprout::is_nothrow_copy_constructible::value) + { + return arr; + } + namespace detail { + template + inline SPROUT_CONSTEXPR sprout::array::type, N> + to_array_impl(T (& arr)[N], sprout::index_tuple) + SPROUT_NOEXCEPT_IF(sprout::is_nothrow_copy_constructible::type>::value) + { + return sprout::array::type, N>{{arr[Indexes]...}}; + } + } // namespace detail + template inline SPROUT_CONSTEXPR sprout::array::type, N> - to_array(T (& arr)[N]) { + to_array(T (& arr)[N]) + SPROUT_NOEXCEPT_IF(sprout::is_nothrow_copy_constructible::type>::value) + { + return sprout::detail::to_array_impl(arr, sprout::make_index_tuple::make()); + } + namespace detail { + template + inline SPROUT_CONSTEXPR sprout::array + to_array_impl(std::array const& arr, sprout::index_tuple) + SPROUT_NOEXCEPT_IF(sprout::is_nothrow_copy_constructible::value) + { + return sprout::array{{arr[Indexes]...}}; + } + } // namespace detail + template + inline SPROUT_CONSTEXPR sprout::array + to_array(std::array const& arr) + SPROUT_NOEXCEPT_IF(sprout::is_nothrow_copy_constructible::value) + { return sprout::detail::to_array_impl(arr, sprout::make_index_tuple::make()); } } // namespace sprout