From b95e5833943bf4dd588dee7b79d2ef12eae4c1fa Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sun, 27 Oct 2013 16:25:13 +0900 Subject: [PATCH] add config: SPROUT_INITIALIZER_LIST_CONSTEXPR --- sprout/algorithm/max.hpp | 18 ++---------------- sprout/algorithm/min.hpp | 18 ++---------------- sprout/algorithm/minmax.hpp | 18 ++---------------- sprout/array/array.hpp | 1 - sprout/config/suffix.hpp | 9 +++++++++ sprout/string/string.hpp | 3 +-- 6 files changed, 16 insertions(+), 51 deletions(-) diff --git a/sprout/algorithm/max.hpp b/sprout/algorithm/max.hpp index 54a8cb6b..1a89fbb9 100644 --- a/sprout/algorithm/max.hpp +++ b/sprout/algorithm/max.hpp @@ -19,31 +19,17 @@ namespace sprout { // 25.4.7 Minimum and maximum -#ifdef SPROUT_NO_CXX14_INITIALIZER_LIST template - inline SPROUT_CONSTEXPR T + inline SPROUT_INITIALIZER_LIST_CONSTEXPR T max(std::initializer_list t, Compare comp) { return *sprout::max_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp); } template - inline SPROUT_CONSTEXPR T + inline SPROUT_INITIALIZER_LIST_CONSTEXPR T max(std::initializer_list t) { return sprout::max(t, NS_SSCRISK_CEL_OR_SPROUT::less()); } -#else // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST - template - inline T - max(std::initializer_list t, Compare comp) { - return *sprout::max_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp); - } - - template - inline T - max(std::initializer_list t) { - return sprout::max(t, NS_SSCRISK_CEL_OR_SPROUT::less()); - } -#endif // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_MAX_HPP diff --git a/sprout/algorithm/min.hpp b/sprout/algorithm/min.hpp index bbf4636f..49c20a7b 100644 --- a/sprout/algorithm/min.hpp +++ b/sprout/algorithm/min.hpp @@ -19,31 +19,17 @@ namespace sprout { // 25.4.7 Minimum and maximum -#ifdef SPROUT_NO_CXX14_INITIALIZER_LIST template - inline SPROUT_CONSTEXPR T + inline SPROUT_INITIALIZER_LIST_CONSTEXPR T min(std::initializer_list t, Compare comp) { return *sprout::min_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp); } template - inline SPROUT_CONSTEXPR T + inline SPROUT_INITIALIZER_LIST_CONSTEXPR T min(std::initializer_list t) { return sprout::min(t, NS_SSCRISK_CEL_OR_SPROUT::less()); } -#else // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST - template - inline T - min(std::initializer_list t, Compare comp) { - return *sprout::min_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp); - } - - template - inline T - min(std::initializer_list t) { - return sprout::min(t, NS_SSCRISK_CEL_OR_SPROUT::less()); - } -#endif // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_MIN_HPP diff --git a/sprout/algorithm/minmax.hpp b/sprout/algorithm/minmax.hpp index 26ff3d2a..7c0c2b8b 100644 --- a/sprout/algorithm/minmax.hpp +++ b/sprout/algorithm/minmax.hpp @@ -38,31 +38,17 @@ namespace sprout { } } // namespace detail -#ifdef SPROUT_NO_CXX14_INITIALIZER_LIST template - inline SPROUT_CONSTEXPR sprout::pair + inline SPROUT_INITIALIZER_LIST_CONSTEXPR sprout::pair minmax(std::initializer_list t, Compare comp) { return sprout::detail::minmax_impl(sprout::minmax_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp)); } template - inline SPROUT_CONSTEXPR sprout::pair + inline SPROUT_INITIALIZER_LIST_CONSTEXPR sprout::pair minmax(std::initializer_list t) { return sprout::minmax(t, NS_SSCRISK_CEL_OR_SPROUT::less()); } -#else // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST - template - inline sprout::pair - minmax(std::initializer_list t, Compare comp) { - return sprout::detail::minmax_impl(sprout::minmax_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp)); - } - - template - inline sprout::pair - minmax(std::initializer_list t) { - return sprout::minmax(t, NS_SSCRISK_CEL_OR_SPROUT::less()); - } -#endif // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_MINMAX_HPP diff --git a/sprout/array/array.hpp b/sprout/array/array.hpp index bbd39c43..67935313 100644 --- a/sprout/array/array.hpp +++ b/sprout/array/array.hpp @@ -9,7 +9,6 @@ #define SPROUT_ARRAY_ARRAY_HPP #include -#include #include #include #include diff --git a/sprout/config/suffix.hpp b/sprout/config/suffix.hpp index d8b6642d..c4f49ef5 100644 --- a/sprout/config/suffix.hpp +++ b/sprout/config/suffix.hpp @@ -40,6 +40,15 @@ # define SPROUT_CXX14_CONSTEXPR #endif // #ifndef SPROUT_CONFIG_DISABLE_CXX14_CONSTEXPR +// +// SPROUT_INITIALIZER_LIST_CONSTEXPR +// +#ifndef SPROUT_NO_CXX14_INITIALIZER_LIST +# define SPROUT_INITIALIZER_LIST_CONSTEXPR SPROUT_CXX14_CONSTEXPR +#else // #ifndef SPROUT_NO_CXX14_INITIALIZER_LIST +# define SPROUT_INITIALIZER_LIST_CONSTEXPR +#endif // #ifndef SPROUT_NO_CXX14_INITIALIZER_LIST + // // SPROUT_DEFAULTED_DEFAULT_CONSTRUCTOR_DECL // SPROUT_DEFAULTED_DESTRUCTOR_DECL diff --git a/sprout/string/string.hpp b/sprout/string/string.hpp index 2ca187ef..673920ca 100644 --- a/sprout/string/string.hpp +++ b/sprout/string/string.hpp @@ -10,7 +10,6 @@ #include #include -#include #include #include #include @@ -363,7 +362,7 @@ namespace sprout { typename sprout::identity::iterator_category*>::type() ) {} - basic_string(std::initializer_list il) + SPROUT_INITIALIZER_LIST_CONSTEXPR basic_string(std::initializer_list il) : impl_type( sprout::make_index_tuple::make(), sprout::detail::string_checked_construct_t(), il.begin(), 0, il.size()