From 6f399977b214acdbd34a319f8f355356988fab85 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Tue, 15 Apr 2014 12:31:13 +0900 Subject: [PATCH] fix make_array (add common type version) --- libs/array/test/array.cpp | 2 +- sprout/array/make_array.hpp | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libs/array/test/array.cpp b/libs/array/test/array.cpp index 2d8d9548..42922dc4 100644 --- a/libs/array/test/array.cpp +++ b/libs/array/test/array.cpp @@ -19,7 +19,7 @@ namespace testspr { SPROUT_STATIC_CONSTEXPR int carr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; SPROUT_STATIC_CONSTEXPR auto arr1 = sprout::to_array(carr); SPROUT_STATIC_CONSTEXPR auto arr2 = sprout::make_array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - SPROUT_STATIC_CONSTEXPR auto arr3 = sprout::make_common_array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + SPROUT_STATIC_CONSTEXPR auto arr3 = sprout::make_array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); TESTSPR_BOTH_ASSERT(testspr::equal(carr, arr1)); TESTSPR_BOTH_ASSERT(testspr::equal(carr, arr2)); diff --git a/sprout/array/make_array.hpp b/sprout/array/make_array.hpp index 987362b2..62e76edf 100644 --- a/sprout/array/make_array.hpp +++ b/sprout/array/make_array.hpp @@ -17,6 +17,11 @@ #include namespace sprout { + namespace detail { + enum make_array_t { + make_array_in_common_elements + }; + } // namespace detail // // make_array // @@ -25,16 +30,15 @@ namespace sprout { make_array(Types&&... args) { return sprout::array::type, sizeof...(Types)>{{T(SPROUT_FORWARD(Types, args))...}}; } - // !!! OLD: -// template -// inline SPROUT_CONSTEXPR sprout::array::type, sizeof...(Types)> -// make_array(Types&&... args) { -// typedef sprout::array< -// typename sprout::common_decay::type, -// sizeof...(Types) -// > type; -// return type{{typename sprout::common_decay::type(SPROUT_FORWARD(Types, args))...}}; -// } + template + inline SPROUT_CONSTEXPR sprout::array::type, sizeof...(Types)> + make_array(Types&&... args) { + typedef sprout::array< + typename sprout::common_decay::type, + sizeof...(Types) + > type; + return type{{typename sprout::common_decay::type(SPROUT_FORWARD(Types, args))...}}; + } // // make_common_array @@ -42,11 +46,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::array::type, sizeof...(Types)> make_common_array(Types&&... args) { - typedef sprout::array< - typename sprout::common_decay::type, - sizeof...(Types) - > type; - return type{{typename sprout::common_decay::type(SPROUT_FORWARD(Types, args))...}}; + return sprout::make_array(SPROUT_FORWARD(Types, args)...); } //