From e4c1e4ba7ae6c963708ca7af9abf3801919f8507 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sat, 8 Oct 2011 15:10:23 +0900 Subject: [PATCH] =?UTF-8?q?auto=5Fconfig.hpp=20=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sprout/array.hpp | 6 +++--- sprout/auto_config.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ sprout/config.hpp | 6 ++++++ sprout/string.hpp | 12 ++++++------ 4 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 sprout/auto_config.hpp diff --git a/sprout/array.hpp b/sprout/array.hpp index c9f0ccbd..3ca32ffc 100644 --- a/sprout/array.hpp +++ b/sprout/array.hpp @@ -12,7 +12,7 @@ #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL -#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION +#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION # include #endif @@ -24,7 +24,7 @@ namespace sprout { class array { public: typedef T value_type; -#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION +#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION typedef sprout::index_iterator iterator; typedef sprout::index_iterator const_iterator; #else @@ -59,7 +59,7 @@ namespace sprout { throw std::out_of_range("array<>: index out of range"); } } -#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION +#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION iterator begin() SPROUT_NOEXCEPT { return iterator(*this, 0); } diff --git a/sprout/auto_config.hpp b/sprout/auto_config.hpp new file mode 100644 index 00000000..ca1668c9 --- /dev/null +++ b/sprout/auto_config.hpp @@ -0,0 +1,41 @@ +#ifndef SPROUT_AUTO_CONFIG_HPP +#define SPROUT_AUTO_CONFIG_HPP + +#include + +// +// SPROUT_CONFIG_DISABLE_CONSTEXPR +// +#ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR +# ifdef BOOST_NO_CONSTEXPR +# if !defined(__GNUC__) \ + || defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) || !defined(__GXX_EXPERIMENTAL_CXX0X__)) +# define SPROUT_CONFIG_DISABLE_CONSTEXPR +# endif +# endif // #ifdef BOOST_NO_CONSTEXPR +#endif // #ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR + +// +// SPROUT_CONFIG_DISABLE_NOEXCEPT +// +#ifndef SPROUT_CONFIG_DISABLE_NOEXCEPT +# ifdef BOOST_NO_NOEXCEPT +# if !defined(__GNUC__) \ + || defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) || !defined(__GXX_EXPERIMENTAL_CXX0X__)) +# define SPROUT_CONFIG_DISABLE_NOEXCEPT +# endif +# endif // #ifdef BOOST_NO_NOEXCEPT +#endif // #ifndef SPROUT_CONFIG_DISABLE_NOEXCEPT + +// +// SPROUT_CONFIG_USE_SSCRISK_CEL +// + +// +// SPROUT_CONFIG_SUPPORT_TEMPORARY_CONTAINER_ITERATION +// +#ifndef SPROUT_CONFIG_SUPPORT_TEMPORARY_CONTAINER_ITERATION +# define SPROUT_CONFIG_SUPPORT_TEMPORARY_CONTAINER_ITERATION +#endif // #ifndef SPROUT_CONFIG_SUPPORT_TEMPORARY_CONTAINER_ITERATION + +#endif // #ifndef SPROUT_AUTO_CONFIG_HPP diff --git a/sprout/config.hpp b/sprout/config.hpp index e17a8f23..d83aa2fb 100644 --- a/sprout/config.hpp +++ b/sprout/config.hpp @@ -29,4 +29,10 @@ # define NS_SSCRISK_CEL_OR_SPROUT_DETAIL sscrisk::cel #endif // #ifndef SPROUT_CONFIG_USE_SSCRISK_CEL +#ifndef SPROUT_CONFIG_SUPPORT_TEMPORARY_CONTAINER_ITERATION +# define SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION 0 +#else // #ifndef SPROUT_CONFIG_SUPPORT_TEMPORARY_CONTAINER_ITERATION +# define SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION 1 +#endif // #ifndef SPROUT_CONFIG_SUPPORT_TEMPORARY_CONTAINER_ITERATION + #endif // #ifndef SPROUT_CONFIG_HPP diff --git a/sprout/string.hpp b/sprout/string.hpp index 116d7fcd..9544b664 100644 --- a/sprout/string.hpp +++ b/sprout/string.hpp @@ -17,7 +17,7 @@ #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL -#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION +#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION # include # include #endif @@ -88,7 +88,7 @@ namespace sprout { static SPROUT_CONSTEXPR int_type eof() SPROUT_NOEXCEPT { return impl_type::eof(); } -#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION +#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION template static SPROUT_CONSTEXPR int compare(CharIterator s1, CharIterator s2, std::size_t n) { return !n ? 0 @@ -135,7 +135,7 @@ namespace sprout { class basic_string { public: typedef T value_type; -#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION +#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION typedef sprout::index_iterator iterator; typedef sprout::index_iterator const_iterator; #else @@ -179,7 +179,7 @@ namespace sprout { { return sprout::basic_string{{(Indexes < n ? s[Indexes] : T())...}, n}; } -#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION +#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION static SPROUT_CONSTEXPR int compare_impl_1(const_iterator dest, size_type pos1, size_type n1, const_iterator s, size_type n2) { return compare_impl_2( traits_type::compare(dest + pos1, s, NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(n1, n2)), @@ -224,7 +224,7 @@ namespace sprout { throw std::out_of_range("basic_string<>: index out of range"); } } -#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION +#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION iterator begin() SPROUT_NOEXCEPT { return iterator(*this, 0); } @@ -430,7 +430,7 @@ namespace sprout { : throw "basic_string<>: index out of range" ; } -#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION +#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION basic_string& assign(const_iterator s, size_type n) { maxcheck(n); for (size_type i = 0; i < n; ++i) {