mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Changes for gcc and clang
This commit is contained in:
parent
87c5daa6c4
commit
c6f3579ad1
@ -213,6 +213,7 @@ namespace details
|
||||
template <typename CharT, std::ptrdiff_t Extent = dynamic_range>
|
||||
class basic_string_span
|
||||
{
|
||||
public:
|
||||
using value_type = CharT;
|
||||
using const_value_type = std::add_const_t<value_type>;
|
||||
using pointer = std::add_pointer_t<value_type>;
|
||||
@ -221,7 +222,6 @@ class basic_string_span
|
||||
using bounds_type = static_bounds<Extent>;
|
||||
using impl_type = span<value_type, Extent>;
|
||||
|
||||
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<CharT, Extent> one, const T& other) noexc
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename Dummy = std::enable_if_t<
|
||||
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value
|
||||
&& !details::is_basic_string_span<T>::value>
|
||||
&& !gsl::details::is_basic_string_span<T>::value>
|
||||
>
|
||||
bool operator==(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
|
||||
{
|
||||
@ -550,6 +550,40 @@ bool operator==(const T& one, gsl::basic_string_span<CharT, Extent> 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 <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator==(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
|
||||
{
|
||||
gsl::basic_string_span<std::add_const_t<CharT>, Extent> tmp(other);
|
||||
return std::equal(one.begin(), one.end(), tmp.begin(), tmp.end());
|
||||
}
|
||||
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator==(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
|
||||
{
|
||||
gsl::basic_string_span<std::add_const_t<CharT>, Extent> tmp(one);
|
||||
return std::equal(tmp.begin(), tmp.end(), other.begin(), other.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
// operator !=
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename = std::enable_if_t<
|
||||
@ -563,13 +597,45 @@ bool operator!=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexc
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename Dummy = std::enable_if_t<
|
||||
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value
|
||||
&& !details::is_basic_string_span<T>::value>
|
||||
&& !gsl::details::is_basic_string_span<T>::value>
|
||||
>
|
||||
bool operator!=(const T& one, gsl::basic_string_span<CharT, Extent> 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 <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator!=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
|
||||
{
|
||||
return !(one == other);
|
||||
}
|
||||
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator!=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
|
||||
{
|
||||
return !(one == other);
|
||||
}
|
||||
#endif
|
||||
|
||||
// operator<
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename = std::enable_if_t<
|
||||
@ -578,13 +644,13 @@ template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T
|
||||
bool operator<(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
|
||||
{
|
||||
gsl::basic_string_span<std::add_const_t<CharT>, 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 <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename Dummy = std::enable_if_t<
|
||||
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value
|
||||
&& !details::is_basic_string_span<T>::value>
|
||||
&& !gsl::details::is_basic_string_span<T>::value>
|
||||
>
|
||||
bool operator<(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
|
||||
{
|
||||
@ -592,6 +658,40 @@ bool operator<(const T& one, gsl::basic_string_span<CharT, Extent> 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 <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator<(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
|
||||
{
|
||||
gsl::basic_string_span<std::add_const_t<CharT>, Extent> tmp(other);
|
||||
return std::lexicographical_compare(one.begin(), one.end(), tmp.begin(), tmp.end());
|
||||
}
|
||||
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator<(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
|
||||
{
|
||||
gsl::basic_string_span<std::add_const_t<CharT>, Extent> tmp(one);
|
||||
return std::lexicographical_compare(tmp.begin(), tmp.end(), other.begin(), other.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
// operator <=
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename = std::enable_if_t<
|
||||
@ -605,13 +705,45 @@ bool operator<=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexc
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename Dummy = std::enable_if_t<
|
||||
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value
|
||||
&& !details::is_basic_string_span<T>::value>
|
||||
&& !gsl::details::is_basic_string_span<T>::value>
|
||||
>
|
||||
bool operator<=(const T& one, gsl::basic_string_span<CharT, Extent> 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 <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator<=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
|
||||
{
|
||||
return !(other < one);
|
||||
}
|
||||
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator<=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
|
||||
{
|
||||
return !(other < one);
|
||||
}
|
||||
#endif
|
||||
|
||||
// operator>
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename = std::enable_if_t<
|
||||
@ -625,13 +757,45 @@ bool operator>(gsl::basic_string_span<CharT, Extent> one, const T& other) noexce
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename Dummy = std::enable_if_t<
|
||||
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value
|
||||
&& !details::is_basic_string_span<T>::value>
|
||||
&& !gsl::details::is_basic_string_span<T>::value>
|
||||
>
|
||||
bool operator>(const T& one, gsl::basic_string_span<CharT, Extent> 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 <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator>(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
|
||||
{
|
||||
return other < one;
|
||||
}
|
||||
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator>(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
|
||||
{
|
||||
return other < one;
|
||||
}
|
||||
#endif
|
||||
|
||||
// operator >=
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename = std::enable_if_t<
|
||||
@ -645,13 +809,45 @@ bool operator>=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexc
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename Dummy = std::enable_if_t<
|
||||
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value
|
||||
&& !details::is_basic_string_span<T>::value>
|
||||
&& !gsl::details::is_basic_string_span<T>::value>
|
||||
>
|
||||
bool operator>=(const T& one, gsl::basic_string_span<CharT, Extent> 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 <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator>=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
|
||||
{
|
||||
return !(one < other);
|
||||
}
|
||||
|
||||
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_range, typename T,
|
||||
typename DataType = typename T::value_type,
|
||||
typename Dummy = std::enable_if_t<
|
||||
!gsl::details::is_span<T>::value
|
||||
&& !gsl::details::is_basic_string_span<T>::value
|
||||
&& std::is_convertible<DataType*, CharT*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>, DataType>::value>
|
||||
>
|
||||
bool operator>=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
|
||||
{
|
||||
return !(one < other);
|
||||
}
|
||||
#endif
|
||||
|
||||
// VS 2013 workarounds
|
||||
#ifdef _MSC_VER
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user