From 5bf09079743dac3611a073e59e190b19b70db1d1 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Wed, 17 Feb 2016 10:06:43 +0900 Subject: [PATCH] add conversion to std::array --- sprout/array/array.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sprout/array/array.hpp b/sprout/array/array.hpp index 8da39792..04063fc9 100644 --- a/sprout/array/array.hpp +++ b/sprout/array/array.hpp @@ -67,6 +67,12 @@ namespace sprout { } public: value_type elems[static_size ? static_size : 1]; + private: + template + SPROUT_CONSTEXPR std::array + to_std_array(sprout::index_tuple) const { + return std::array{{elems[Indexes]...}}; + } public: // construct/copy/destroy: template @@ -258,6 +264,10 @@ namespace sprout { return sprout::distance(begin(), p); } #endif + + SPROUT_CONSTEXPR operator std::array() const { + return to_std_array(sprout::make_index_tuple::make()); + } }; template SPROUT_CONSTEXPR_OR_CONST typename sprout::array::size_type sprout::array::static_size;