diff --git a/sprout/algorithm/string/join.hpp b/sprout/algorithm/string/join.hpp index b51bb47b..f10657c4 100644 --- a/sprout/algorithm/string/join.hpp +++ b/sprout/algorithm/string/join.hpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -40,19 +39,19 @@ namespace sprout { > {}; - template< - typename String, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::container_traits::difference_type + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::is_c_str::value, + typename sprout::container_traits::difference_type + >::type str_size(String const& str) { return sprout::size(str) - 1; } - template< - typename String, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::container_traits::difference_type + template + inline SPROUT_CONSTEXPR typename std::enable_if< + !sprout::is_c_str::value, + typename sprout::container_traits::difference_type + >::type str_size(String const& str) { return sprout::size(str); } @@ -230,38 +229,36 @@ namespace sprout { ; } - template< - typename ContainerContainer, - typename sprout::enabler_if< - sprout::is_random_access_iterator< - typename sprout::container_traits::iterator - >::value + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::is_random_access_iterator< + typename sprout::container_traits::iterator + >::value && sprout::is_random_access_iterator< typename sprout::container_traits< typename sprout::container_traits::value_type >::iterator >::value - >::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::algorithm::result_of::join::type + , + typename sprout::algorithm::result_of::join::type + >::type join(ContainerContainer const& cont_cont) { typedef typename sprout::algorithm::result_of::join::type result_type; return sprout::algorithm::detail::join_impl_ra(cont_cont); } - template< - typename ContainerContainer, - typename sprout::enabler_if::iterator - >::value + template + inline SPROUT_CONSTEXPR typename std::enable_if::iterator + >::value && sprout::is_random_access_iterator< typename sprout::container_traits< typename sprout::container_traits::value_type >::iterator >::value - )>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::algorithm::result_of::join::type + ), + typename sprout::algorithm::result_of::join::type + >::type join(ContainerContainer const& cont_cont) { typedef typename sprout::algorithm::result_of::join::type result_type; return sprout::algorithm::detail::join_impl( @@ -457,13 +454,11 @@ namespace sprout { ; } - template< - typename ContainerContainer, - typename Separator, - typename sprout::enabler_if< - sprout::is_random_access_iterator< - typename sprout::container_traits::iterator - >::value + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::is_random_access_iterator< + typename sprout::container_traits::iterator + >::value && sprout::is_random_access_iterator< typename sprout::container_traits< typename sprout::container_traits::value_type @@ -472,20 +467,18 @@ namespace sprout { && sprout::is_random_access_iterator< typename sprout::container_traits::iterator >::value - >::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::algorithm::result_of::join::type + , + typename sprout::algorithm::result_of::join::type + >::type join(ContainerContainer const& cont_cont, Separator const& separator) { - typedef typename sprout::algorithm::result_of::join::type result_type; + typedef typename sprout::algorithm::result_of::join::type result_type; return sprout::algorithm::detail::join_impl_ra(cont_cont, separator); } - template< - typename ContainerContainer, - typename Separator, - typename sprout::enabler_if::iterator - >::value + template + inline SPROUT_CONSTEXPR typename std::enable_if::iterator + >::value && sprout::is_random_access_iterator< typename sprout::container_traits< typename sprout::container_traits::value_type @@ -494,11 +487,11 @@ namespace sprout { && sprout::is_random_access_iterator< typename sprout::container_traits::iterator >::value - )>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::algorithm::result_of::join::type + ), + typename sprout::algorithm::result_of::join::type + >::type join(ContainerContainer const& cont_cont, Separator const& separator) { - typedef typename sprout::algorithm::result_of::join::type result_type; + typedef typename sprout::algorithm::result_of::join::type result_type; return sprout::algorithm::detail::join_impl( sprout::begin(cont_cont), sprout::end(cont_cont), diff --git a/sprout/bit/clz.hpp b/sprout/bit/clz.hpp index b7685f5f..afc32edc 100644 --- a/sprout/bit/clz.hpp +++ b/sprout/bit/clz.hpp @@ -28,13 +28,19 @@ namespace sprout { : 1 + sprout::detail::clz_impl(n, static_cast(m >> 1)) ; } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR int + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_unsigned::value, + int + >::type clz(T n) { return sprout::detail::clz_impl(static_cast(n)); } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR int + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_signed::value, + int + >::type clz(T n) { return sprout::detail::clz(static_cast::type>(n)); } @@ -42,8 +48,11 @@ namespace sprout { // // clz // - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR int + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value, + int + >::type clz(T n) { return sprout::detail::clz(n); } diff --git a/sprout/bit/ctz.hpp b/sprout/bit/ctz.hpp index 06eb7622..3f51a6b2 100644 --- a/sprout/bit/ctz.hpp +++ b/sprout/bit/ctz.hpp @@ -20,15 +20,21 @@ namespace sprout { return __builtin_ctzll(n); } # endif - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR int + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_unsigned::value, + int + >::type ctz(T n) { return n & 1 ? 0 : 1 + sprout::detail::ctz(static_cast(n >> 1)) ; } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR int + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_signed::value, + int + >::type ctz(T n) { return sprout::detail::ctz(static_cast::type>(n)); } @@ -36,8 +42,11 @@ namespace sprout { // // ctz // - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR int + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value, + int + >::type ctz(T n) { return sprout::detail::ctz(n); } diff --git a/sprout/bit/popcount.hpp b/sprout/bit/popcount.hpp index 7067735d..32d62236 100644 --- a/sprout/bit/popcount.hpp +++ b/sprout/bit/popcount.hpp @@ -3,7 +3,6 @@ #include #include -#include namespace sprout { namespace detail { @@ -21,15 +20,21 @@ namespace sprout { return __builtin_popcountll(n); } # endif - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR int + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_unsigned::value, + int + >::type popcount(T n) { return n == 0 ? 0 : 1 + sprout::detail::popcount(static_cast(n & (n - 1))) ; } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR int + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_signed::value, + int + >::type popcount(T n) { return sprout::detail::popcount(static_cast::type>(n)); } @@ -37,8 +42,11 @@ namespace sprout { // // popcount // - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR int + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value, + int + >::type popcount(T n) { return sprout::detail::popcount(n); } diff --git a/sprout/bit/rotate.hpp b/sprout/bit/rotate.hpp index 242ee03d..fa6dc0b9 100644 --- a/sprout/bit/rotate.hpp +++ b/sprout/bit/rotate.hpp @@ -5,14 +5,16 @@ #include #include #include -#include namespace sprout { // // left_rotate // - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR T + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value, + T + >::type left_rotate(T x, std::size_t n) { return (x << n) ^ (x >> (sizeof(T) * CHAR_BIT - n)); } @@ -20,8 +22,11 @@ namespace sprout { // // right_rotate // - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR T + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value, + T + >::type right_rotate(T x, std::size_t n) { return (x >> n) ^ (x << (sizeof(T) * CHAR_BIT - n)); } diff --git a/sprout/cinttypes/abs.hpp b/sprout/cinttypes/abs.hpp index c787b8cc..2e5ec0b1 100644 --- a/sprout/cinttypes/abs.hpp +++ b/sprout/cinttypes/abs.hpp @@ -2,9 +2,7 @@ #define SPROUT_CINTTYPES_ABS_HPP #include -#include #include -#include namespace sprout { inline SPROUT_CONSTEXPR std::intmax_t diff --git a/sprout/cinttypes/div.hpp b/sprout/cinttypes/div.hpp index 119d5a18..a2d4c887 100644 --- a/sprout/cinttypes/div.hpp +++ b/sprout/cinttypes/div.hpp @@ -4,12 +4,26 @@ #include #include #include -#include +#if !defined(_MSC_VER) +# include +#endif #include #include -#include namespace sprout { + // + // imaxdiv_t + // +#if defined(_MSC_VER) + struct imaxdiv_t { + public: + std::intmax_t quot; + std::intmax_t rem; + }; +#else + typedef std::imaxdiv_t imaxdiv_t; +#endif + namespace detail { template struct div_t_traits2 {}; @@ -23,42 +37,48 @@ namespace sprout { SPROUT_STATIC_CONSTEXPR std::size_t offsetof_rem = offsetof(DIV_T, rem); \ } - SPROUT_DETAIL_DIV_T_TRAITS2_IMPL(std::intmax_t, std::imaxdiv_t); + SPROUT_DETAIL_DIV_T_TRAITS2_IMPL(std::intmax_t, sprout::imaxdiv_t); # undef SPROUT_DETAIL_DIV_T_TRAITS2_IMPL - template< - typename T, - typename sprout::enabler_if< - sprout::detail::div_t_traits2::offsetof_quot == 0 - >::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::detail::div_t_traits2::type + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::detail::div_t_traits2::offsetof_quot == 0, + typename sprout::detail::div_t_traits2::type + >::type div_impl2(T const& numer, T const& denom) { +#if defined(_MSC_VER) + typename sprout::detail::div_t_traits2::type result = {numer / denom, numer % denom}; + return result; +#else return {numer / denom, numer % denom}; +#endif } - template< - typename T, - typename sprout::enabler_if< - sprout::detail::div_t_traits2::offsetof_rem == 0 - >::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::detail::div_t_traits2::type + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::detail::div_t_traits2::offsetof_rem == 0, + typename sprout::detail::div_t_traits2::type + >::type div_impl2(T const &numer, T const& denom) { +#if defined(_MSC_VER) + typename sprout::detail::div_t_traits2::type result = {numer % denom, numer / denom}; + return result; +#else return {numer % denom, numer / denom}; +#endif } } // namespace detail - inline SPROUT_CONSTEXPR std::imaxdiv_t + inline SPROUT_CONSTEXPR sprout::imaxdiv_t imaxdiv(std::intmax_t numer, std::intmax_t denom) { return sprout::detail::div_impl2(numer, denom); } - template< - typename T, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR std::imaxdiv_t + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_same::value, + sprout::imaxdiv_t + >::type div(T numer, T denom) { return sprout::imaxdiv(numer, denom); } diff --git a/sprout/container/weak_rebind_size.hpp b/sprout/container/weak_rebind_size.hpp index 4deda56f..08bfac35 100644 --- a/sprout/container/weak_rebind_size.hpp +++ b/sprout/container/weak_rebind_size.hpp @@ -15,10 +15,17 @@ namespace sprout { std::true_type sprout_has_xxx_impl_check_template_rebind_size(int); template std::false_type sprout_has_xxx_impl_check_template_rebind_size(long); +#if defined(_MSC_VER) + template(0))> + struct has_rebind_size + : public Base_ + {}; +#else template struct has_rebind_size - : decltype(sprout::containers::detail::sprout_has_xxx_impl_check_template_rebind_size(0)) + : public decltype(sprout::containers::detail::sprout_has_xxx_impl_check_template_rebind_size(0)) {}; +#endif } // namespace detail // // is_rebindable_size diff --git a/sprout/cstdlib/abs.hpp b/sprout/cstdlib/abs.hpp index 46f5323f..2976eb71 100644 --- a/sprout/cstdlib/abs.hpp +++ b/sprout/cstdlib/abs.hpp @@ -3,7 +3,6 @@ #include #include -#include namespace sprout { // Copyright (C) 2011 RiSK (sscrisk) @@ -35,23 +34,20 @@ namespace sprout { } namespace { - template< - typename IntType, - typename sprout::enabler_if< - std::is_integral::value && std::is_signed::value - >::type = sprout::enabler - > - inline SPROUT_CONSTEXPR IntType + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value && std::is_signed::value, + IntType + >::type abs(IntType j) { return j < 0 ? -j : j; } - template< - typename IntType, - typename sprout::enabler_if< - std::is_integral::value && std::is_unsigned::value - >::type = sprout::enabler - > - inline SPROUT_CONSTEXPR IntType + + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value && std::is_unsigned::value, + IntType + >::type abs(IntType j) { return j; } diff --git a/sprout/cstdlib/ascii_to_int.hpp b/sprout/cstdlib/ascii_to_int.hpp index 2507265a..f67a1fb0 100644 --- a/sprout/cstdlib/ascii_to_int.hpp +++ b/sprout/cstdlib/ascii_to_int.hpp @@ -7,7 +7,6 @@ #include #include #include -#include namespace sprout { namespace detail { @@ -27,8 +26,11 @@ namespace sprout { ) ; } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR IntType + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_unsigned::value, + IntType + >::type ascii_to_int(CStrIterator str) { return sprout::ascii::isspace(*str) ? sprout::detail::ascii_to_int(sprout::next(str)) @@ -37,8 +39,11 @@ namespace sprout { : sprout::detail::ascii_to_int_impl(str, IntType(), false) ; } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR IntType + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_signed::value, + IntType + >::type ascii_to_int(CStrIterator str) { return sprout::ascii::isspace(*str) ? sprout::detail::ascii_to_int(sprout::next(str)) @@ -54,8 +59,11 @@ namespace sprout { // // ascii_to_int // - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR IntType + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value, + IntType + >::type ascii_to_int(Char const* str) { return sprout::detail::ascii_to_int(str); } diff --git a/sprout/cstdlib/div.hpp b/sprout/cstdlib/div.hpp index b41851d5..df0934c9 100644 --- a/sprout/cstdlib/div.hpp +++ b/sprout/cstdlib/div.hpp @@ -5,7 +5,6 @@ #include #include #include -#include namespace sprout { // Copyright (C) 2011 RiSK (sscrisk) @@ -28,26 +27,32 @@ namespace sprout { SPROUT_DETAIL_DIV_T_TRAITS_IMPL(long long, std::lldiv_t); # undef SPROUT_DETAIL_DIV_T_TRAITS_IMPL - template< - typename T, - typename sprout::enabler_if< - sprout::detail::div_t_traits::offsetof_quot == 0 - >::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::detail::div_t_traits::type + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::detail::div_t_traits::offsetof_quot == 0, + typename sprout::detail::div_t_traits::type + >::type div_impl(T const& numer, T const& denom) { +#if defined(_MSC_VER) + typename sprout::detail::div_t_traits::type result = {numer / denom, numer % denom}; + return result; +#else return {numer / denom, numer % denom}; +#endif } - template< - typename T, - typename sprout::enabler_if< - sprout::detail::div_t_traits::offsetof_rem == 0 - >::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::detail::div_t_traits::type + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::detail::div_t_traits::offsetof_rem == 0, + typename sprout::detail::div_t_traits::type + >::type div_impl(T const &numer, T const& denom) { +#if defined(_MSC_VER) + typename sprout::detail::div_t_traits::type result = {numer % denom, numer / denom}; + return result; +#else return {numer % denom, numer / denom}; +#endif } } // namespace detail diff --git a/sprout/cstdlib/str_to_float.hpp b/sprout/cstdlib/str_to_float.hpp index 901179b0..9de23e0a 100644 --- a/sprout/cstdlib/str_to_float.hpp +++ b/sprout/cstdlib/str_to_float.hpp @@ -8,7 +8,6 @@ #include #include #include -#include namespace sprout { namespace detail { @@ -246,18 +245,29 @@ namespace sprout { // // str_to_float // - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR FloatType + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_floating_point::value, + FloatType + >::type str_to_float(Char const* str, Char** endptr) { return sprout::detail::str_to_float(str, endptr); } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR FloatType + + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_floating_point::value, + FloatType + >::type str_to_float(Char const* str, std::nullptr_t endptr) { return sprout::detail::str_to_float(str); } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR FloatType + + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_floating_point::value, + FloatType + >::type str_to_float(Char const* str) { return sprout::detail::str_to_float(str); } diff --git a/sprout/cstdlib/str_to_int.hpp b/sprout/cstdlib/str_to_int.hpp index 44539471..864c8f44 100644 --- a/sprout/cstdlib/str_to_int.hpp +++ b/sprout/cstdlib/str_to_int.hpp @@ -3,13 +3,14 @@ #include #include -#include +#if !defined(_MSC_VER) +# include +#endif #include #include #include #include #include -#include #include namespace sprout { @@ -60,8 +61,11 @@ namespace sprout { ) ; } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR IntType + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_unsigned::value, + IntType + >::type str_to_int(CStrIterator str, int base) { return sprout::ascii::isspace(*str) ? sprout::detail::str_to_int(sprout::next(str), base) @@ -70,8 +74,11 @@ namespace sprout { : sprout::detail::str_to_int_impl(str, base, false) ; } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR IntType + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_signed::value, + IntType + >::type str_to_int(CStrIterator str, int base) { return sprout::ascii::isspace(*str) ? sprout::detail::str_to_int(sprout::next(str), base) @@ -85,6 +92,13 @@ namespace sprout { template inline SPROUT_CONSTEXPR IntType str_to_int(CStrIterator str, CharPtr* endptr, int base) { +#if defined(_MSC_VER) + return !endptr ? sprout::detail::str_to_int(str, base) + : std::is_signed::value + ? static_cast(std::strtol(&*str, endptr, base)) + : static_cast(std::strtoul(&*str, endptr, base)) + ; +#else return !endptr ? sprout::detail::str_to_int(str, base) : std::is_signed::value ? sizeof(IntType) <= sizeof(long) ? static_cast(std::strtol(&*str, endptr, base)) @@ -94,24 +108,36 @@ namespace sprout { : sizeof(IntType) <= sizeof(unsigned long long) ? static_cast(std::strtoull(&*str, endptr, base)) : static_cast(std::strtoumax(&*str, endptr, base)) ; +#endif } } // namespace detail // // str_to_int // - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR IntType + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value, + IntType + >::type str_to_int(Char const* str, Char** endptr, int base = 10) { return sprout::detail::str_to_int(str, endptr, base); } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR IntType + + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value, + IntType + >::type str_to_int(Char const* str, std::nullptr_t endptr, int base = 10) { return sprout::detail::str_to_int(str, base); } - template::value>::type = sprout::enabler> - inline SPROUT_CONSTEXPR IntType + + template + inline SPROUT_CONSTEXPR typename std::enable_if< + std::is_integral::value, + IntType + >::type str_to_int(Char const* str, int base = 10) { return sprout::detail::str_to_int(str, base); } diff --git a/sprout/detail/algorithm/overlap_count.hpp b/sprout/detail/algorithm/overlap_count.hpp index 16115031..4ad04896 100644 --- a/sprout/detail/algorithm/overlap_count.hpp +++ b/sprout/detail/algorithm/overlap_count.hpp @@ -4,15 +4,49 @@ #include #include #include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace detail { + template + inline SPROUT_CONSTEXPR typename std::iterator_traits::difference_type + overlap_count_impl_ra( + RandomAccessIterator first, RandomAccessIterator last, BinaryPredicate pred, + typename std::iterator_traits::difference_type pivot + ) + { + return pivot == 0 ? (pred(*first, *last) ? 1 : 0) + : sprout::detail::overlap_count_impl_ra( + first, sprout::next(first, pivot), pred, + pivot / 2 + ) + + sprout::detail::overlap_count_impl_ra( + sprout::next(first, pivot), last, pred, + (NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2 + ) + ; + } + template + inline SPROUT_CONSTEXPR typename std::iterator_traits::difference_type + overlap_count( + RandomAccessIterator first, RandomAccessIterator last, BinaryPredicate pred, + std::random_access_iterator_tag* + ) + { + return first == last || NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) == 1 ? 0 + : sprout::detail::overlap_count_impl_ra( + first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - 1), pred, + (NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - 1) / 2 + ) + ; + } + template inline SPROUT_CONSTEXPR typename std::iterator_traits::difference_type overlap_count_impl( - InputIterator first, InputIterator last, - BinaryPredicate pred, typename std::iterator_traits::value_type const& value + InputIterator first, InputIterator last, BinaryPredicate pred, + typename std::iterator_traits::value_type const& value ) { return first == last ? 0 @@ -20,6 +54,17 @@ namespace sprout { : sprout::detail::overlap_count_impl(sprout::next(first), last, pred, *first) ; } + template + inline SPROUT_CONSTEXPR typename std::iterator_traits::difference_type + overlap_count_impl( + InputIterator first, InputIterator last, BinaryPredicate pred, + void* + ) + { + return first == last ? 0 + : sprout::detail::overlap_count_impl(sprout::next(first), last, pred, *first) + ; + } // // overlap_count @@ -27,9 +72,8 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename std::iterator_traits::difference_type overlap_count(InputIterator first, InputIterator last, BinaryPredicate pred) { - return first == last ? 0 - : sprout::detail::overlap_count_impl(sprout::next(first), last, pred, *first) - ; + typedef typename std::iterator_traits::iterator_category* category; + return sprout::detail::overlap_count(first, last, pred, category()); } template diff --git a/sprout/generator/generated_value.hpp b/sprout/generator/generated_value.hpp index 555f8e2a..6745ec56 100644 --- a/sprout/generator/generated_value.hpp +++ b/sprout/generator/generated_value.hpp @@ -28,10 +28,17 @@ namespace sprout_generator_detail { static std::true_type test(int); static std::false_type test(...); }; +#if defined(_MSC_VER) + template::test(0))> + struct has_adl_generated_value + : public Base_ + {}; +#else template struct has_adl_generated_value : public decltype(sprout_generator_detail::has_adl_generated_value_test::test(0)) {}; +#endif template struct has_mem_generated_value_test { @@ -43,10 +50,17 @@ namespace sprout_generator_detail { static std::true_type test(int); static std::false_type test(...); }; +#if defined(_MSC_VER) + template::test(0))> + struct has_mem_generated_value + : public Base_ + {}; +#else template struct has_mem_generated_value : public decltype(sprout_generator_detail::has_mem_generated_value_test::test(0)) {}; +#endif template struct has_get_generated_value_test { @@ -58,10 +72,17 @@ namespace sprout_generator_detail { static std::true_type test(int); static std::false_type test(...); }; +#if defined(_MSC_VER) + template::test(0))> + struct has_get_generated_value + : public Base_ + {}; +#else template struct has_get_generated_value : public decltype(sprout_generator_detail::has_get_generated_value_test::test(0)) {}; +#endif template struct select_adl_generated_value; diff --git a/sprout/generator/next_generator.hpp b/sprout/generator/next_generator.hpp index 47932258..643808fc 100644 --- a/sprout/generator/next_generator.hpp +++ b/sprout/generator/next_generator.hpp @@ -28,10 +28,17 @@ namespace sprout_generator_detail { static std::true_type test(int); static std::false_type test(...); }; +#if defined(_MSC_VER) + template::test(0))> + struct has_adl_next_generator + : public Base_ + {}; +#else template struct has_adl_next_generator : public decltype(sprout_generator_detail::has_adl_next_generator_test::test(0)) {}; +#endif template struct has_mem_next_generator_test { @@ -43,10 +50,17 @@ namespace sprout_generator_detail { static std::true_type test(int); static std::false_type test(...); }; +#if defined(_MSC_VER) + template::test(0))> + struct has_mem_next_generator + : public Base_ + {}; +#else template struct has_mem_next_generator : public decltype(sprout_generator_detail::has_mem_next_generator_test::test(0)) {}; +#endif template struct has_get_next_generator_test { @@ -58,10 +72,17 @@ namespace sprout_generator_detail { static std::true_type test(int); static std::false_type test(...); }; +#if defined(_MSC_VER) + template::test(0))> + struct has_get_next_generator + : public Base_ + {}; +#else template struct has_get_next_generator : public decltype(sprout_generator_detail::has_get_next_generator_test::test(0)) {}; +#endif template struct select_adl_next_generator; diff --git a/sprout/tuple/tuple/get.hpp b/sprout/tuple/tuple/get.hpp index 674ecafe..a66743e7 100644 --- a/sprout/tuple/tuple/get.hpp +++ b/sprout/tuple/tuple/get.hpp @@ -120,10 +120,17 @@ namespace sprout_tuple_detail { static std::true_type test(int); static std::false_type test(...); }; +#if defined(_MSC_VER) + template::test(0))> + struct has_adl_tuple_get + : public Base_ + {}; +#else template struct has_adl_tuple_get : public decltype(sprout_tuple_detail::has_adl_tuple_get_test::test(0)) {}; +#endif template struct has_std_get_test { @@ -135,10 +142,17 @@ namespace sprout_tuple_detail { static std::true_type test(int); static std::false_type test(...); }; +#if defined(_MSC_VER) + template::test(0))> + struct has_std_get + : public Base_ + {}; +#else template struct has_std_get : public decltype(sprout_tuple_detail::has_std_get_test::test(0)) {}; +#endif template struct select_adl_tuple_get; diff --git a/sprout/type_traits/has_xxx.hpp b/sprout/type_traits/has_xxx.hpp index 8240a53b..c30d9e60 100644 --- a/sprout/type_traits/has_xxx.hpp +++ b/sprout/type_traits/has_xxx.hpp @@ -9,6 +9,17 @@ // SPROUT_HAS_XXX_TYPE_DEF // SPROUT_HAS_XXX_TYPE_DEF_LAZY // +#if defined(_MSC_VER) +#define SPROUT_HAS_XXX_TYPE_DEF(NAME, TYPE) \ + template \ + std::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), __LINE__)(int); \ + template \ + std::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), __LINE__)(long); \ + template(0))> \ + struct NAME \ + : public Base_ \ + {} +#else #define SPROUT_HAS_XXX_TYPE_DEF(NAME, TYPE) \ template \ std::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), __LINE__)(int); \ @@ -16,8 +27,9 @@ std::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), __LINE__)(long); \ template \ struct NAME \ - : decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), __LINE__)(0)) \ + : public decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), __LINE__)(0)) \ {} +#endif #define SPROUT_HAS_XXX_TYPE_DEF_LAZY(TYPE) \ SPROUT_HAS_XXX_TYPE_DEF(SPROUT_PP_CAT(has_, TYPE), TYPE) @@ -25,6 +37,17 @@ // SPROUT_HAS_XXX_VALUE_DEF // SPROUT_HAS_XXX_VALUE_DEF_LAZY // +#if defined(_MSC_VER) +#define SPROUT_HAS_XXX_VALUE_DEF(NAME, VALUE) \ + template \ + std::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), __LINE__)(int); \ + template \ + std::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), __LINE__)(long); \ + template(0))> \ + struct NAME \ + : public Base_ \ + {} +#else #define SPROUT_HAS_XXX_VALUE_DEF(NAME, VALUE) \ template \ std::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), __LINE__)(int); \ @@ -32,8 +55,9 @@ std::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), __LINE__)(long); \ template \ struct NAME \ - : decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), __LINE__)(0)) \ + : public decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), __LINE__)(0)) \ {} +#endif #define SPROUT_HAS_XXX_VALUE_DEF_LAZY(VALUE) \ SPROUT_HAS_XXX_VALUE_DEF(SPROUT_PP_CAT(has_, VALUE), VALUE)