Merge pull request #204 from annagrin/dev/annagrin/fix_conversion_bug

Fixed conversion problem when creating strided_span from span and bounds
This commit is contained in:
Neil MacIntosh 2015-11-19 17:57:07 -08:00
commit 04050a2162
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