mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
For VS2013, fix an ICE by replacing dummy template type parameter by a dummy function parameter
This commit is contained in:
parent
37cdb6bc50
commit
5e7e68c8b0
@ -34,6 +34,7 @@
|
||||
#if _MSC_VER <= 1800
|
||||
|
||||
#define GSL_MSVC_HAS_TYPE_DEDUCTION_BUG
|
||||
#define GSL_MSVC2013_ICE_WHEN_USING_DUMMY_TEMPLATE_PARAMETER
|
||||
|
||||
// noexcept is not understood
|
||||
#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
|
||||
@ -283,6 +284,74 @@ public:
|
||||
: span_(&(s.at(0)), narrow_cast<std::ptrdiff_t>(s.length()))
|
||||
{}
|
||||
|
||||
#ifdef GSL_MSVC2013_ICE_WHEN_USING_DUMMY_TEMPLATE_PARAMETER
|
||||
template<
|
||||
typename Cont,
|
||||
typename DataType = typename Cont::value_type
|
||||
>
|
||||
constexpr basic_string_span(
|
||||
Cont& cont,
|
||||
std::enable_if_t<
|
||||
!details::is_span<Cont>::value
|
||||
&& !details::is_basic_string_span<Cont>::value
|
||||
&& !(!std::is_const<value_type>::value && std::is_const<Cont>::value)
|
||||
&& std::is_convertible<DataType*, value_type*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<Cont>().size(), *std::declval<Cont>().data())>, DataType>::value
|
||||
>* = nullptr
|
||||
)
|
||||
: span_(cont.data(), cont.size())
|
||||
{}
|
||||
|
||||
// disallow creation from temporary containers and strings
|
||||
template<
|
||||
typename Cont,
|
||||
typename DataType = typename Cont::value_type
|
||||
>
|
||||
explicit basic_string_span(
|
||||
Cont&& cont
|
||||
,
|
||||
std::enable_if_t<
|
||||
!details::is_span<Cont>::value
|
||||
&& !details::is_basic_string_span<Cont>::value
|
||||
&& std::is_convertible<DataType*, value_type*>::value
|
||||
&& std::is_same<std::decay_t<decltype(std::declval<Cont>().size(), *std::declval<Cont>().data())>, DataType>::value
|
||||
>* = nullptr
|
||||
) = delete;
|
||||
|
||||
// from span
|
||||
template<
|
||||
typename OtherValueType,
|
||||
std::ptrdiff_t... OtherDimensions,
|
||||
typename OtherBounds = static_bounds<OtherDimensions...>
|
||||
>
|
||||
constexpr basic_string_span(
|
||||
span<OtherValueType, OtherDimensions...> other,
|
||||
typename std::enable_if<
|
||||
std::is_convertible<OtherValueType, value_type>::value &&
|
||||
std::is_convertible<OtherBounds, bounds_type>::value
|
||||
>::type* = nullptr
|
||||
) noexcept
|
||||
: span_(other)
|
||||
{}
|
||||
|
||||
// from string_span
|
||||
template<
|
||||
typename OtherValueType,
|
||||
std::ptrdiff_t OtherExtent,
|
||||
typename OtherBounds = static_bounds<OtherExtent>
|
||||
>
|
||||
constexpr basic_string_span(
|
||||
basic_string_span<OtherValueType, OtherExtent> other,
|
||||
std::enable_if_t<
|
||||
std::is_convertible<OtherValueType*, value_type*>::value
|
||||
&& std::is_convertible<OtherBounds, bounds_type>::value
|
||||
>* = nullptr
|
||||
) noexcept
|
||||
: span_(other.data(), other.length())
|
||||
{}
|
||||
|
||||
#else // GSL_MSVC2013_ICE_WHEN_USING_DUMMY_TEMPLATE_PARAMETER
|
||||
|
||||
// from containers. Containers must have .size() and .data() function signatures
|
||||
template <typename Cont, typename DataType = typename Cont::value_type,
|
||||
typename Dummy = std::enable_if_t<!details::is_span<Cont>::value
|
||||
@ -321,6 +390,7 @@ public:
|
||||
constexpr basic_string_span(basic_string_span<OtherValueType, OtherExtent> other) noexcept
|
||||
: span_(other.data(), other.length())
|
||||
{}
|
||||
#endif // GSL_MSVC2013_ICE_WHEN_USING_DUMMY_TEMPLATE_PARAMETER
|
||||
|
||||
constexpr bool empty() const noexcept
|
||||
{
|
||||
@ -581,6 +651,7 @@ bool operator>=(const gsl::basic_string_span<CharT, Extent>& one, const gsl::bas
|
||||
#pragma pop_macro("noexcept")
|
||||
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
|
||||
|
||||
#undef GSL_MSVC2013_ICE_WHEN_USING_DUMMY_TEMPLATE_PARAMETER
|
||||
#undef GSL_MSVC_HAS_TYPE_DEDUCTION_BUG
|
||||
|
||||
#endif // _MSC_VER <= 1800
|
||||
|
Loading…
Reference in New Issue
Block a user