From f38ee4fb5e58b6bb88b723578661e1ad3744e3a2 Mon Sep 17 00:00:00 2001 From: Pascal Menuet Date: Sat, 12 Dec 2015 22:59:57 +0100 Subject: [PATCH] In VS2013, the std::equal does not have the overload that takes 4 iterators --- include/string_span.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/string_span.h b/include/string_span.h index 01c56dc..03ef07a 100644 --- a/include/string_span.h +++ b/include/string_span.h @@ -35,6 +35,7 @@ #define GSL_MSVC_HAS_TYPE_DEDUCTION_BUG #define GSL_MSVC2013_ICE_WHEN_USING_DUMMY_TEMPLATE_PARAMETER +#define GSL_MSVC2013_EQUAL_ALGORITHM_IS_NOT_CPP14 // noexcept is not understood #ifndef GSL_THROW_ON_CONTRACT_VIOLATION @@ -611,7 +612,13 @@ using wzstring_builder = basic_zstring_builder; template bool operator==(const gsl::basic_string_span& one, const gsl::basic_string_span& other) noexcept { +#ifdef GSL_MSVC2013_EQUAL_ALGORITHM_IS_NOT_CPP14 + if (std::distance(one.begin(), one.end()) != std::distance(other.begin(), other.end())) + return false; + return std::equal(one.begin(), one.end(), other.begin()); +#else return std::equal(one.begin(), one.end(), other.begin(), other.end()); +#endif } template @@ -651,6 +658,7 @@ bool operator>=(const gsl::basic_string_span& one, const gsl::bas #pragma pop_macro("noexcept") #endif // GSL_THROW_ON_CONTRACT_VIOLATION +#undef GSL_MSVC2013_EQUAL_ALGORITHM_IS_NOT_CPP14 #undef GSL_MSVC2013_ICE_WHEN_USING_DUMMY_TEMPLATE_PARAMETER #undef GSL_MSVC_HAS_TYPE_DEDUCTION_BUG