diff --git a/sprout/algorithm/max.hpp b/sprout/algorithm/max.hpp index bb4e8023..db3b6e7e 100644 --- a/sprout/algorithm/max.hpp +++ b/sprout/algorithm/max.hpp @@ -9,7 +9,10 @@ #ifndef SPROUT_ALGORITHM_MAX_HPP #define SPROUT_ALGORITHM_MAX_HPP +#include #include +#include +#include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT namespace sprout { @@ -26,6 +29,32 @@ namespace sprout { max(T const& a, T const& b) { return sprout::max(a, b, NS_SSCRISK_CEL_OR_SPROUT::less()); } + +#ifdef SPROUT_NO_CXX14_INITIALIZER_LIST + template + inline SPROUT_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 + 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 26588639..586cd8ec 100644 --- a/sprout/algorithm/min.hpp +++ b/sprout/algorithm/min.hpp @@ -9,7 +9,10 @@ #ifndef SPROUT_ALGORITHM_MIN_HPP #define SPROUT_ALGORITHM_MIN_HPP +#include #include +#include +#include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT namespace sprout { @@ -26,6 +29,32 @@ namespace sprout { min(T const& a, T const& b) { return sprout::min(a, b, NS_SSCRISK_CEL_OR_SPROUT::less()); } + +#ifdef SPROUT_NO_CXX14_INITIALIZER_LIST + template + inline SPROUT_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 + 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/non_modifying.hpp b/sprout/algorithm/non_modifying.hpp index cd48fc81..9053016b 100644 --- a/sprout/algorithm/non_modifying.hpp +++ b/sprout/algorithm/non_modifying.hpp @@ -43,8 +43,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/sprout/config/stdlib/dinkumware.hpp b/sprout/config/stdlib/dinkumware.hpp index e29f777d..115e986e 100644 --- a/sprout/config/stdlib/dinkumware.hpp +++ b/sprout/config/stdlib/dinkumware.hpp @@ -44,4 +44,6 @@ #define SPROUT_NO_CXX11_HDR_INITIALIZER_LIST +#define SPROUT_NO_CXX14_INITIALIZER_LIST + #endif // #ifndef SPROUT_CONFIG_STDLIB_DINKUMWARE_HPP diff --git a/sprout/config/stdlib/libcomo.hpp b/sprout/config/stdlib/libcomo.hpp index efee3cb9..48555830 100644 --- a/sprout/config/stdlib/libcomo.hpp +++ b/sprout/config/stdlib/libcomo.hpp @@ -33,4 +33,6 @@ #define SPROUT_NO_CXX11_SMART_PTR #define SPROUT_NO_CXX11_HDR_FUNCTIONAL +#define SPROUT_NO_CXX14_INITIALIZER_LIST + #endif // #ifndef SPROUT_CONFIG_STDLIB_LIBCOMO_HPP diff --git a/sprout/config/stdlib/libcpp.hpp b/sprout/config/stdlib/libcpp.hpp index 4f9b82ba..33663442 100644 --- a/sprout/config/stdlib/libcpp.hpp +++ b/sprout/config/stdlib/libcpp.hpp @@ -23,4 +23,6 @@ # define SPROUT_NO_CXX11_NUMERIC_LIMITS #endif +#define SPROUT_NO_CXX14_INITIALIZER_LIST + #endif // #ifndef SPROUT_CONFIG_STDLIB_LIBCPP_HPP diff --git a/sprout/config/stdlib/libstdcpp3.hpp b/sprout/config/stdlib/libstdcpp3.hpp index 0e3851a2..18f3eeaf 100644 --- a/sprout/config/stdlib/libstdcpp3.hpp +++ b/sprout/config/stdlib/libstdcpp3.hpp @@ -63,4 +63,8 @@ #define SPROUT_NO_CXX11_HDR_CODECVT #define SPROUT_NO_CXX11_ATOMIC_SMART_PTR +#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) || !defined(__GXX_EXPERIMENTAL_CXX0X__)) +# define SPROUT_NO_CXX14_INITIALIZER_LIST +#endif + #endif // #ifndef SPROUT_CONFIG_STDLIB_LIBSTDCPP3_HPP diff --git a/sprout/config/stdlib/modena.hpp b/sprout/config/stdlib/modena.hpp index 8d2410b8..d0ce9cb6 100644 --- a/sprout/config/stdlib/modena.hpp +++ b/sprout/config/stdlib/modena.hpp @@ -33,4 +33,6 @@ #define SPROUT_NO_CXX11_SMART_PTR #define SPROUT_NO_CXX11_HDR_FUNCTIONAL +#define SPROUT_NO_CXX14_INITIALIZER_LIST + #endif // #ifndef SPROUT_CONFIG_STDLIB_MODENA_HPP diff --git a/sprout/config/stdlib/msl.hpp b/sprout/config/stdlib/msl.hpp index 89c562b4..4c01dc66 100644 --- a/sprout/config/stdlib/msl.hpp +++ b/sprout/config/stdlib/msl.hpp @@ -33,4 +33,6 @@ #define SPROUT_NO_CXX11_SMART_PTR #define SPROUT_NO_CXX11_HDR_FUNCTIONAL +#define SPROUT_NO_CXX14_INITIALIZER_LIST + #endif // #ifndef SPROUT_CONFIG_STDLIB_MSL_HPP diff --git a/sprout/config/stdlib/roguewave.hpp b/sprout/config/stdlib/roguewave.hpp index 84e3839d..1a41cf6a 100644 --- a/sprout/config/stdlib/roguewave.hpp +++ b/sprout/config/stdlib/roguewave.hpp @@ -36,4 +36,6 @@ #define SPROUT_NO_CXX11_SMART_PTR #define SPROUT_NO_CXX11_HDR_FUNCTIONAL +#define SPROUT_NO_CXX14_INITIALIZER_LIST + #endif // #ifndef SPROUT_CONFIG_STDLIB_ROGUEWAVE_HPP diff --git a/sprout/config/stdlib/sgi.hpp b/sprout/config/stdlib/sgi.hpp index b3394344..e4e2f71c 100644 --- a/sprout/config/stdlib/sgi.hpp +++ b/sprout/config/stdlib/sgi.hpp @@ -33,4 +33,6 @@ #define SPROUT_NO_CXX11_SMART_PTR #define SPROUT_NO_CXX11_HDR_FUNCTIONAL +#define SPROUT_NO_CXX14_INITIALIZER_LIST + #endif // #ifndef SPROUT_CONFIG_STDLIB_SGI_HPP diff --git a/sprout/config/stdlib/stlport.hpp b/sprout/config/stdlib/stlport.hpp index b63ee9a5..d8ad3ca8 100644 --- a/sprout/config/stdlib/stlport.hpp +++ b/sprout/config/stdlib/stlport.hpp @@ -33,4 +33,6 @@ #define SPROUT_NO_CXX11_SMART_PTR #define SPROUT_NO_CXX11_HDR_FUNCTIONAL +#define SPROUT_NO_CXX14_INITIALIZER_LIST + #endif // #ifndef SPROUT_CONFIG_STDLIB_STLPORT_HPP diff --git a/sprout/config/stdlib/vacpp.hpp b/sprout/config/stdlib/vacpp.hpp index 40568d0d..825c10c0 100644 --- a/sprout/config/stdlib/vacpp.hpp +++ b/sprout/config/stdlib/vacpp.hpp @@ -33,4 +33,6 @@ #define SPROUT_NO_CXX11_SMART_PTR #define SPROUT_NO_CXX11_HDR_FUNCTIONAL +#define SPROUT_NO_CXX14_INITIALIZER_LIST + #endif // #ifndef SPROUT_CONFIG_STDLIB_VACPP_HPP