From c6f3579ad1502015e320facf882f54caefbc266b Mon Sep 17 00:00:00 2001 From: Anna Gringauze Date: Sat, 5 Dec 2015 01:03:19 +0000 Subject: [PATCH] Changes for gcc and clang --- include/string_span.h | 212 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 204 insertions(+), 8 deletions(-) diff --git a/include/string_span.h b/include/string_span.h index 8418029..6b0b32b 100644 --- a/include/string_span.h +++ b/include/string_span.h @@ -213,6 +213,7 @@ namespace details template class basic_string_span { +public: using value_type = CharT; using const_value_type = std::add_const_t; using pointer = std::add_pointer_t; @@ -221,7 +222,6 @@ class basic_string_span using bounds_type = static_bounds; using impl_type = span; -public: using size_type = ptrdiff_t; using iterator = typename impl_type::iterator; using const_iterator = typename impl_type::const_iterator; @@ -542,7 +542,7 @@ bool operator==(gsl::basic_string_span one, const T& other) noexc template , Extent>>::value - && !details::is_basic_string_span::value> + && !gsl::details::is_basic_string_span::value> > bool operator==(const T& one, gsl::basic_string_span other) noexcept { @@ -550,6 +550,40 @@ bool operator==(const T& one, gsl::basic_string_span other) noexc return std::equal(tmp.begin(), tmp.end(), other.begin(), other.end()); } +#ifndef _MSC_VER + +// VS allows temp and const containers as convertible to basic_string_span, +// to the cases below are already by the revious operators + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator==(gsl::basic_string_span one, const T& other) noexcept +{ + gsl::basic_string_span, Extent> tmp(other); + return std::equal(one.begin(), one.end(), tmp.begin(), tmp.end()); +} + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator==(const T& one, gsl::basic_string_span other) noexcept +{ + gsl::basic_string_span, Extent> tmp(one); + return std::equal(tmp.begin(), tmp.end(), other.begin(), other.end()); +} +#endif + // operator != template one, const T& other) noexc template , Extent>>::value - && !details::is_basic_string_span::value> + && !gsl::details::is_basic_string_span::value> > bool operator!=(const T& one, gsl::basic_string_span other) noexcept { return !(one == other); } +#ifndef _MSC_VER + +// VS allows temp and const containers as convertible to basic_string_span, +// to the cases below are already by the revious operators + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator!=(gsl::basic_string_span one, const T& other) noexcept +{ + return !(one == other); +} + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator!=(const T& one, gsl::basic_string_span other) noexcept +{ + return !(one == other); +} +#endif + // operator< template one, const T& other) noexcept { gsl::basic_string_span, Extent> tmp(other); - return std::lexicographical_compare(one.begin(), one.end(), other.begin(), other.end()); + return std::lexicographical_compare(one.begin(), one.end(), tmp.begin(), tmp.end()); } template , Extent>>::value - && !details::is_basic_string_span::value> + && !gsl::details::is_basic_string_span::value> > bool operator<(const T& one, gsl::basic_string_span other) noexcept { @@ -592,6 +658,40 @@ bool operator<(const T& one, gsl::basic_string_span other) noexce return std::lexicographical_compare(tmp.begin(), tmp.end(), other.begin(), other.end()); } +#ifndef _MSC_VER + +// VS allows temp and const containers as convertible to basic_string_span, +// to the cases below are already by the revious operators + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator<(gsl::basic_string_span one, const T& other) noexcept +{ + gsl::basic_string_span, Extent> tmp(other); + return std::lexicographical_compare(one.begin(), one.end(), tmp.begin(), tmp.end()); +} + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator<(const T& one, gsl::basic_string_span other) noexcept +{ + gsl::basic_string_span, Extent> tmp(one); + return std::lexicographical_compare(tmp.begin(), tmp.end(), other.begin(), other.end()); +} +#endif + // operator <= template one, const T& other) noexc template , Extent>>::value - && !details::is_basic_string_span::value> + && !gsl::details::is_basic_string_span::value> > bool operator<=(const T& one, gsl::basic_string_span other) noexcept { return !(other < one); } +#ifndef _MSC_VER + +// VS allows temp and const containers as convertible to basic_string_span, +// to the cases below are already by the revious operators + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator<=(gsl::basic_string_span one, const T& other) noexcept +{ + return !(other < one); +} + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator<=(const T& one, gsl::basic_string_span other) noexcept +{ + return !(other < one); +} +#endif + // operator> template (gsl::basic_string_span one, const T& other) noexce template , Extent>>::value - && !details::is_basic_string_span::value> + && !gsl::details::is_basic_string_span::value> > bool operator>(const T& one, gsl::basic_string_span other) noexcept { return other < one; } +#ifndef _MSC_VER + +// VS allows temp and const containers as convertible to basic_string_span, +// to the cases below are already by the revious operators + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator>(gsl::basic_string_span one, const T& other) noexcept +{ + return other < one; +} + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator>(const T& one, gsl::basic_string_span other) noexcept +{ + return other < one; +} +#endif + // operator >= template =(gsl::basic_string_span one, const T& other) noexc template , Extent>>::value - && !details::is_basic_string_span::value> + && !gsl::details::is_basic_string_span::value> > bool operator>=(const T& one, gsl::basic_string_span other) noexcept { return !(one < other); } +#ifndef _MSC_VER + +// VS allows temp and const containers as convertible to basic_string_span, +// to the cases below are already by the revious operators + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator>=(gsl::basic_string_span one, const T& other) noexcept +{ + return !(one < other); +} + +template ::value + && !gsl::details::is_basic_string_span::value + && std::is_convertible::value + && std::is_same().size(), *std::declval().data())>, DataType>::value> +> +bool operator>=(const T& one, gsl::basic_string_span other) noexcept +{ + return !(one < other); +} +#endif + // VS 2013 workarounds #ifdef _MSC_VER