Fixed conversion problem when creating strided_span from span and bounds

This commit is contained in:
Anna Gringauze 2015-11-19 12:02:06 -08:00
parent 4552575e34
commit c95eb57d3f
2 changed files with 10 additions and 6 deletions

View File

@ -1610,8 +1610,12 @@ public:
{}
// from array view
template <std::ptrdiff_t... Dimensions, typename Dummy = std::enable_if<sizeof...(Dimensions) == Rank>>
constexpr strided_span(span<ValueType, Dimensions...> av, bounds_type bounds) : strided_span(av.data(), av.bounds().total_size(), std::move(bounds))
template <typename OtherValueType, std::ptrdiff_t... Dimensions,
bool Enabled1 = (sizeof...(Dimensions) == Rank),
bool Enabled2 = std::is_convertible<OtherValueType*, ValueType*>::value,
typename Dummy = std::enable_if_t<Enabled1 && Enabled2>
>
constexpr strided_span(span<OtherValueType, Dimensions...> av, bounds_type bounds) : strided_span(av.data(), av.bounds().total_size(), std::move(bounds))
{}
// convertible

View File

@ -333,7 +333,7 @@ SUITE(span_tests)
CHECK(sav_c[1] == 2);
#if _MSC_VER > 1800
strided_span<volatile int, 1> sav_v{ {src}, {2, 1} };
strided_span<volatile int, 1> sav_v{ src, {2, 1} };
#else
strided_span<volatile int, 1> sav_v{ span<volatile int>{src}, strided_bounds<1>{2, 1} };
#endif
@ -342,7 +342,7 @@ SUITE(span_tests)
CHECK(sav_v[1] == 2);
#if _MSC_VER > 1800
strided_span<const volatile int, 1> sav_cv{ {src}, {2, 1} };
strided_span<const volatile int, 1> sav_cv{ src, {2, 1} };
#else
strided_span<const volatile int, 1> sav_cv{ span<const volatile int>{src}, strided_bounds<1>{2, 1} };
#endif
@ -361,7 +361,7 @@ SUITE(span_tests)
CHECK(sav_c[1] == 2);
#if _MSC_VER > 1800
strided_span<const volatile int, 1> sav_cv{ {src}, {2, 1} };
strided_span<const volatile int, 1> sav_cv{ src, {2, 1} };
#else
strided_span<const volatile int, 1> sav_cv{ span<const volatile int>{src}, strided_bounds<1>{2, 1} };
#endif
@ -381,7 +381,7 @@ SUITE(span_tests)
CHECK(sav_v[1] == 2);
#if _MSC_VER > 1800
strided_span<const volatile int, 1> sav_cv{ {src}, {2, 1} };
strided_span<const volatile int, 1> sav_cv{ src, {2, 1} };
#else
strided_span<const volatile int, 1> sav_cv{ span<const volatile int>{src}, strided_bounds<1>{2, 1} };
#endif