add config: SPROUT_INITIALIZER_LIST_CONSTEXPR

This commit is contained in:
bolero-MURAKAMI 2013-10-27 16:25:13 +09:00
parent 3267d11b4a
commit b95e583394
6 changed files with 16 additions and 51 deletions

View file

@ -19,31 +19,17 @@
namespace sprout {
// 25.4.7 Minimum and maximum
#ifdef SPROUT_NO_CXX14_INITIALIZER_LIST
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR T
inline SPROUT_INITIALIZER_LIST_CONSTEXPR T
max(std::initializer_list<T> t, Compare comp) {
return *sprout::max_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp);
}
template<typename T>
inline SPROUT_CONSTEXPR T
inline SPROUT_INITIALIZER_LIST_CONSTEXPR T
max(std::initializer_list<T> t) {
return sprout::max(t, NS_SSCRISK_CEL_OR_SPROUT::less<T>());
}
#else // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST
template<typename T, typename Compare>
inline T
max(std::initializer_list<T> t, Compare comp) {
return *sprout::max_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp);
}
template<typename T>
inline T
max(std::initializer_list<T> t) {
return sprout::max(t, NS_SSCRISK_CEL_OR_SPROUT::less<T>());
}
#endif // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST
} // namespace sprout
#endif // #ifndef SPROUT_ALGORITHM_MAX_HPP

View file

@ -19,31 +19,17 @@
namespace sprout {
// 25.4.7 Minimum and maximum
#ifdef SPROUT_NO_CXX14_INITIALIZER_LIST
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR T
inline SPROUT_INITIALIZER_LIST_CONSTEXPR T
min(std::initializer_list<T> t, Compare comp) {
return *sprout::min_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp);
}
template<typename T>
inline SPROUT_CONSTEXPR T
inline SPROUT_INITIALIZER_LIST_CONSTEXPR T
min(std::initializer_list<T> t) {
return sprout::min(t, NS_SSCRISK_CEL_OR_SPROUT::less<T>());
}
#else // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST
template<typename T, typename Compare>
inline T
min(std::initializer_list<T> t, Compare comp) {
return *sprout::min_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp);
}
template<typename T>
inline T
min(std::initializer_list<T> t) {
return sprout::min(t, NS_SSCRISK_CEL_OR_SPROUT::less<T>());
}
#endif // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST
} // namespace sprout
#endif // #ifndef SPROUT_ALGORITHM_MIN_HPP

View file

@ -38,31 +38,17 @@ namespace sprout {
}
} // namespace detail
#ifdef SPROUT_NO_CXX14_INITIALIZER_LIST
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<T, T>
inline SPROUT_INITIALIZER_LIST_CONSTEXPR sprout::pair<T, T>
minmax(std::initializer_list<T> t, Compare comp) {
return sprout::detail::minmax_impl<T>(sprout::minmax_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp));
}
template<typename T>
inline SPROUT_CONSTEXPR sprout::pair<T, T>
inline SPROUT_INITIALIZER_LIST_CONSTEXPR sprout::pair<T, T>
minmax(std::initializer_list<T> t) {
return sprout::minmax(t, NS_SSCRISK_CEL_OR_SPROUT::less<T>());
}
#else // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST
template<typename T, typename Compare>
inline sprout::pair<T, T>
minmax(std::initializer_list<T> t, Compare comp) {
return sprout::detail::minmax_impl<T>(sprout::minmax_element(sprout::ptr_index(t.begin(), 0), sprout::ptr_index(t.begin(), t.size()), comp));
}
template<typename T>
inline sprout::pair<T, T>
minmax(std::initializer_list<T> t) {
return sprout::minmax(t, NS_SSCRISK_CEL_OR_SPROUT::less<T>());
}
#endif // #ifdef SPROUT_NO_CXX14_INITIALIZER_LIST
} // namespace sprout
#endif // #ifndef SPROUT_ALGORITHM_MINMAX_HPP

View file

@ -9,7 +9,6 @@
#define SPROUT_ARRAY_ARRAY_HPP
#include <cstddef>
#include <algorithm>
#include <utility>
#include <stdexcept>
#include <sprout/config.hpp>

View file

@ -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

View file

@ -10,7 +10,6 @@
#include <cstddef>
#include <string>
#include <algorithm>
#include <iterator>
#include <utility>
#include <stdexcept>
@ -363,7 +362,7 @@ namespace sprout {
typename sprout::identity<typename std::iterator_traits<InputIterator>::iterator_category*>::type()
)
{}
basic_string(std::initializer_list<value_type> il)
SPROUT_INITIALIZER_LIST_CONSTEXPR basic_string(std::initializer_list<value_type> il)
: impl_type(
sprout::make_index_tuple<N>::make(),
sprout::detail::string_checked_construct_t(), il.begin(), 0, il.size()