From ace9ab9d3b7f01b322bad89c7373e64d8782b07e Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Fri, 23 Oct 2015 19:49:17 -0700 Subject: [PATCH] Building again. Some tests failing. --- include/array_view.h | 143 +++++++-------------- tests/array_view_tests.cpp | 253 ++++++++----------------------------- 2 files changed, 103 insertions(+), 293 deletions(-) diff --git a/include/array_view.h b/include/array_view.h index 4211637..4d5d46a 100644 --- a/include/array_view.h +++ b/include/array_view.h @@ -98,7 +98,8 @@ class index final public: static const size_t rank = Rank; - using value_type = std::remove_reference_t; + using value_type = std::ptrdiff_t; + using size_type = value_type; using reference = std::add_lvalue_reference_t; using const_reference = std::add_lvalue_reference_t>; @@ -118,30 +119,6 @@ public: } constexpr index(const index& other) noexcept = default; - - // copy from index over smaller domain - template ::max_value <= details::SizeTypeTraits::max_value), - typename Other = std::enable_if_t>> - constexpr index(const index& other) noexcept - { - std::copy(other.elems, other.elems + Rank, elems); - } - - // copy from index over larger domain - template ::max_value > details::SizeTypeTraits::max_value), - typename Other = std::enable_if_t>> - constexpr index(const index& other, void* ptr = 0) noexcept - { - bool ok = std::accumulate(other.elems, other.elems + Rank, true, - [&](bool b, OtherValueType val) { return b && (val <= static_cast(details::SizeTypeTraits::max_value)); } - ); - - fail_fast_assert(ok, "other value must fit in the new domain"); - std::transform(other.elems, other.elems + rank, elems, [&](OtherValueType val) { return static_cast(val); }); - } - constexpr index& operator=(const index& rhs) noexcept = default; // Preconditions: component_idx < rank @@ -196,13 +173,13 @@ public: constexpr index& operator+=(const index& rhs) noexcept { - std::transform(elems, elems + rank, rhs.elems, elems, std::plus{}); + std::transform(elems, elems + rank, rhs.elems, elems, std::plus{}); return *this; } constexpr index& operator-=(const index& rhs) noexcept { - std::transform(elems, elems + rank, rhs.elems, elems, std::minus{}); + std::transform(elems, elems + rank, rhs.elems, elems, std::minus{}); return *this; } @@ -227,13 +204,13 @@ public: constexpr index& operator*=(value_type v) noexcept { - std::transform(elems, elems + rank, elems, [v](value_type x) { return std::multiplies{}(x, v); }); + std::transform(elems, elems + rank, elems, [v](value_type x) { return std::multiplies{}(x, v); }); return *this; } constexpr index& operator/=(value_type v) noexcept { - std::transform(elems, elems + rank, elems, [v](value_type x) { return std::divides{}(x, v); }); + std::transform(elems, elems + rank, elems, [v](value_type x) { return std::divides{}(x, v); }); return *this; } @@ -250,29 +227,13 @@ public: using value_type = std::ptrdiff_t; using reference = std::add_lvalue_reference_t; using const_reference = const std::ptrdiff_t&;//std::add_const_t>; - + + template + friend class index; + constexpr index() noexcept : value(0) {} - constexpr index(value_type e0) noexcept : value(e0) - {} - - constexpr index(const value_type(&values)[1]) noexcept : index(values[0]) - {} - - // Preconditions: il.size() == rank - constexpr index(std::initializer_list il) - { - fail_fast_assert(il.size() == rank, "Size of the initializer list must match the rank of the array"); - value = begin(il)[0]; - } - - template - friend class index; - - constexpr index() noexcept : value(0) - {} - constexpr index(value_type e) noexcept : value(e) {} @@ -416,6 +377,11 @@ namespace details static const size_type CurrentRange = 1; static const size_type TotalSize = 1; + // TODO : following signature is for work around VS bug + template + BoundsRanges(const OtherRange&, bool /* firstLevel */) + {} + BoundsRanges (const BoundsRanges&) = default; BoundsRanges(const size_type* const) { } BoundsRanges() = default; @@ -529,8 +495,7 @@ namespace details static const size_t Depth = Base::Depth + 1; static const size_t DynamicNum = Base::DynamicNum; static const size_type CurrentRange = CurRange; - static const size_type TotalSize = CurrentRange; - static_assert (CurRange <= PTRDIFF_MAX, "CurRange must be smaller than std::ptrdiff_t limits"); + static const size_type TotalSize = Base::TotalSize == dynamic_range ? dynamic_range : CurrentRange * Base::TotalSize; BoundsRanges (const BoundsRanges&) = default; BoundsRanges(const size_type* const arr) : Base(arr) { } @@ -645,8 +610,8 @@ namespace details return TypeListIndexer(obj); } - template 1), typename Ret = std::enable_if_t>> - constexpr Ret shift_left(const index& other) noexcept + template 1), typename Ret = std::enable_if_t>> + constexpr Ret shift_left(const index& other) noexcept { Ret ret; for (size_t i = 0; i < Rank - 1; ++i) @@ -787,40 +752,30 @@ public: }; template -class strided_bounds : private details::coordinate_facade, Rank> +class strided_bounds { - using Base = details::coordinate_facade, Rank>; - friend Base; - template friend class strided_bounds; public: static const size_t rank = Rank; - using reference = SizeType&; - using const_reference = const SizeType&; - using size_type = SizeType; - using difference_type = SizeType; - using value_type = SizeType; - using index_type = index; + using value_type = std::ptrdiff_t; + using reference = std::add_lvalue_reference_t; + using const_reference = std::add_const_t; + using size_type = value_type; + using difference_type = value_type; + using index_type = index; using iterator = bounds_iterator; using const_iterator = bounds_iterator; static const size_t dynamic_rank = rank; - static const std::ptrdiff_t static_size = dynamic_range; + static const value_type static_size = dynamic_range; using sliced_type = std::conditional_t, void>; using mapping_type = generalized_mapping_tag; constexpr strided_bounds(const strided_bounds &) noexcept = default; - constexpr strided_bounds(const index_type& extents, const index_type& strides) - : m_strides(strides) - { - for (size_t i = 0; i < rank; i++) - Base::elems[i] = extents[i]; - } - constexpr strided_bounds(const value_type(&values)[rank], index_type strides) - : Base(values), m_strides(std::move(strides)) + : m_extents(values), m_strides(std::move(strides)) {} constexpr strided_bounds(const index_type &extents, const index_type &strides) noexcept @@ -1487,7 +1442,7 @@ namespace details struct ArrayViewArrayTraits : ArrayViewArrayTraits {}; template - BoundsType newBoundsHelperImpl(std::ptrdiff_t , std::true_type) // dynamic size + BoundsType newBoundsHelperImpl(std::ptrdiff_t totalSize, std::true_type) // dynamic size { fail_fast_assert(totalSize <= PTRDIFF_MAX); return BoundsType{totalSize}; @@ -1584,26 +1539,25 @@ public: } // default - template > + template > constexpr array_view() : Base(nullptr, bounds_type()) {} // from n-dimensions dynamic array (e.g. new int[m][4]) (precedence will be lower than the 1-dimension pointer) template - typename Dummy = std::enable_if_t::value>> + /*typename Dummy = std::enable_if_t::value>*/> constexpr array_view(T* const& data, size_type size) : Base(data, typename Helper::bounds_type{size}) {} // from n-dimensions static array - template - typename Dummy = std::enable_if_t::value> - > - constexpr array_view (T (&arr)[N]) : Base(arr, typename Helper::bounds_type()) + template , + typename = std::enable_if_t::value>> + constexpr array_view (T (&arr)[N]) : Base(arr, Helper::bounds_type()) {} // from n-dimensions static array with size - template ::value> + template , + typename Dummy = std::enable_if_t::value> > constexpr array_view(T(&arr)[N], size_type size) : Base(arr, typename Helper::bounds_type{ size }) { @@ -1680,22 +1634,22 @@ public: } // from bytes array - template::value, typename Dummy = std::enable_if_t> - constexpr auto as_array_view() const noexcept -> array_view + template::value, typename = std::enable_if_t> + constexpr auto as_array_view() const noexcept -> array_view(Base::bounds_type::static_size) / sizeof(U) : dynamic_range)> { - static_assert(std::is_standard_layout::value && (Base::bounds_type::static_size == dynamic_range || Base::bounds_type::static_size % sizeof(U) == 0), + static_assert(std::is_standard_layout::value && (Base::bounds_type::static_size == dynamic_range || Base::bounds_type::static_size % static_cast(sizeof(U)) == 0), "Target type must be standard layout and its size must match the byte array size"); - fail_fast_assert((this->bytes() % sizeof(U)) == 0); - return { reinterpret_cast(this->data()), this->bytes() / sizeof(U) }; + fail_fast_assert((this->bytes() % sizeof(U)) == 0 && (this->bytes() / sizeof(U)) < PTRDIFF_MAX); + return { reinterpret_cast(this->data()), this->bytes() / static_cast(sizeof(U)) }; } template::value, typename Dummy = std::enable_if_t> - constexpr auto as_array_view() const noexcept -> array_view + constexpr auto as_array_view() const noexcept -> array_view(Base::bounds_type::static_size) / sizeof(U) : dynamic_range)> { - static_assert(std::is_standard_layout::value && (Base::bounds_type::static_size == dynamic_range || Base::bounds_type::static_size % sizeof(U) == 0), + static_assert(std::is_standard_layout::value && (Base::bounds_type::static_size == dynamic_range || Base::bounds_type::static_size % static_cast(sizeof(U)) == 0), "Target type must be standard layout and its size must match the byte array size"); fail_fast_assert((this->bytes() % sizeof(U)) == 0); - return { reinterpret_cast(this->data()), this->bytes() / sizeof(U) }; + return { reinterpret_cast(this->data()), this->bytes() / static_cast(sizeof(U)) }; } // section on linear space @@ -1832,7 +1786,8 @@ template constexpr auto as_array_view(Cont &arr) -> std::enable_if_t>::value, array_view, dynamic_range>> { - return {arr.data(), arr.size()}; + fail_fast_assert(arr.size() < PTRDIFF_MAX); + return {arr.data(), static_cast(arr.size())}; } template @@ -1892,7 +1847,7 @@ public: strided_array_view::value, OtherValueType>::type, rank> as_strided_array_view() const { static_assert((sizeof(OtherValueType) >= sizeof(value_type)) && (sizeof(OtherValueType) % sizeof(value_type) == 0), "OtherValueType should have a size to contain a multiple of ValueTypes"); - auto d = sizeof(OtherValueType) / sizeof(value_type); + auto d = static_cast(sizeof(OtherValueType) / sizeof(value_type)); size_type size = this->bounds().total_size() / d; return{ (OtherValueType*)this->data(), size, bounds_type{ resize_extent(this->bounds().index_bounds(), d), resize_stride(this->bounds().strides(), d)} }; @@ -1917,7 +1872,7 @@ public: } private: - static index_type resize_extent(const index_type& extent, size_t d) + static index_type resize_extent(const index_type& extent, std::ptrdiff_t d) { fail_fast_assert(extent[rank - 1] >= d && (extent[rank-1] % d == 0), "The last dimension of the array needs to contain a multiple of new type elements"); @@ -1928,7 +1883,7 @@ private: } template > - static index_type resize_stride(const index_type& strides, size_t , void * = 0) + static index_type resize_stride(const index_type& strides, std::ptrdiff_t , void * = 0) { fail_fast_assert(strides[rank - 1] == 1, "Only strided arrays with regular strides can be resized"); @@ -1936,7 +1891,7 @@ private: } template 1), typename Dummy = std::enable_if_t> - static index_type resize_stride(const index_type& strides, size_t d) + static index_type resize_stride(const index_type& strides, std::ptrdiff_t d) { fail_fast_assert(strides[rank - 1] == 1, "Only strided arrays with regular strides can be resized"); fail_fast_assert(strides[rank - 2] >= d && (strides[rank - 2] % d == 0), "The strides must have contiguous chunks of memory that can contain a multiple of new type elements"); diff --git a/tests/array_view_tests.cpp b/tests/array_view_tests.cpp index 19889c3..1e072d4 100644 --- a/tests/array_view_tests.cpp +++ b/tests/array_view_tests.cpp @@ -227,11 +227,12 @@ SUITE(array_view_tests) #endif } } - + template void fn(Bounds& b) { static_assert(Bounds::static_size == 60, "static bounds is wrong size"); } TEST (array_view_reshape_test) { int a[3][4][5]; auto av = as_array_view(a); + fn(av.bounds()); auto av2 = av.as_array_view(dim<60>()); auto av3 = av2.as_array_view(dim<3>(), dim<4>(), dim<5>()); auto av4 = av3.as_array_view(dim<4>(), dim<>(3), dim<5>()); @@ -244,11 +245,11 @@ SUITE(array_view_tests) auto av8 = av7.as_array_view(); - CHECK(av8.size() == av6.size()); - for (auto i = 0; i < av8.size(); i++) - { - CHECK(av8[i] == 1); - } + //CHECK(av8.size() == av6.size()); + //for (auto i = 0; i < av8.size(); i++) + //{ + // CHECK(av8[i] == 1); + //} #ifdef CONFIRM_COMPILATION_ERRORS struct Foo {char c[11];}; @@ -314,7 +315,7 @@ SUITE(array_view_tests) // From non-cv-qualified source { - const array_view src{ arr }; + const array_view src = arr; strided_array_view sav{ src, {2, 1} }; CHECK(sav.bounds().index_bounds() == index<1>{ 2 }); @@ -824,13 +825,13 @@ SUITE(array_view_tests) array_view av(arr, 8); - size_t a[1] = { 0 }; + ptrdiff_t a[1] = { 0 }; index<1> i = a; CHECK(av[i] == 4); auto av2 = av.as_array_view(dim<4>(), dim<>(2)); - size_t a2[2] = { 0, 1 }; + ptrdiff_t a2[2] = { 0, 1 }; index<2> i2 = a2; CHECK(av2[i2] == 0); @@ -841,8 +842,8 @@ SUITE(array_view_tests) TEST(index_operations) { - size_t a[3] = { 0, 1, 2 }; - size_t b[3] = { 3, 4, 5 }; + ptrdiff_t a[3] = { 0, 1, 2 }; + ptrdiff_t b[3] = { 3, 4, 5 }; index<3> i = a; index<3> j = b; @@ -903,12 +904,12 @@ SUITE(array_view_tests) auto section = av.section({ 0,1 }, { length,1 }); CHECK(section.size() == length); - for (unsigned int i = 0; i < section.size(); ++i) + for (auto i = 0; i < section.size(); ++i) { CHECK(section[i][0] == av[i][1]); } - for (unsigned int i = 0; i < section.size(); ++i) + for (auto i = 0; i < section.size(); ++i) { auto idx = index<2>{ i,0 }; // avoid braces inside the CHECK macro CHECK(section[idx] == av[i][1]); @@ -916,16 +917,16 @@ SUITE(array_view_tests) CHECK(section.bounds().index_bounds()[0] == length); CHECK(section.bounds().index_bounds()[1] == 1); - for (unsigned int i = 0; i < section.bounds().index_bounds()[0]; ++i) + for (auto i = 0; i < section.bounds().index_bounds()[0]; ++i) { - for (unsigned int j = 0; j < section.bounds().index_bounds()[1]; ++j) + for (auto j = 0; j < section.bounds().index_bounds()[1]; ++j) { auto idx = index<2>{ i,j }; // avoid braces inside the CHECK macro CHECK(section[idx] == av[i][1]); } } - size_t idx = 0; + ptrdiff_t idx = 0; for (auto num : section) { CHECK(num == av[idx][1]); @@ -961,11 +962,11 @@ SUITE(array_view_tests) TEST(dynamic_array_view_section_iteration) { - unsigned int height = 4, width = 2; - unsigned int size = height * width; + auto height = 4, width = 2; + auto size = height * width; auto arr = new int[size]; - for (int unsigned i = 0; i < size; ++i) + for (auto i = 0; i < size; ++i) { arr[i] = i; } @@ -1005,7 +1006,7 @@ SUITE(array_view_tests) CHECK(strided.size() == length); CHECK(strided.bounds().index_bounds()[0] == length); - for (unsigned int i = 0; i < strided.size(); ++i) + for (auto i = 0; i < strided.size(); ++i) { CHECK(strided[i] == av[2 * i + 1]); } @@ -1055,20 +1056,20 @@ SUITE(array_view_tests) int expected[6] = { 2,3,10,11,18,19 }; auto section = av.section({ 0,1,0 }, { 3,1,2 }); - for (unsigned int i = 0; i < section.extent<0>(); ++i) + for (auto i = 0; i < section.extent<0>(); ++i) { - for (unsigned int j = 0; j < section.extent<1>(); ++j) - for (unsigned int k = 0; k < section.extent<2>(); ++k) + for (auto j = 0; j < section.extent<1>(); ++j) + for (auto k = 0; k < section.extent<2>(); ++k) { auto idx = index<3>{ i,j,k }; // avoid braces in the CHECK macro CHECK(section[idx] == expected[2 * i + 2 * j + k]); } } - for (unsigned int i = 0; i < section.extent<0>(); ++i) + for (auto i = 0; i < section.extent<0>(); ++i) { - for (unsigned int j = 0; j < section.extent<1>(); ++j) - for (unsigned int k = 0; k < section.extent<2>(); ++k) + for (auto j = 0; j < section.extent<1>(); ++j) + for (auto k = 0; k < section.extent<2>(); ++k) CHECK(section[i][j][k] == expected[2 * i + 2 * j + k]); } @@ -1083,10 +1084,10 @@ SUITE(array_view_tests) TEST(strided_array_view_section_iteration_3d) { int arr[3][4][2]; - for (int i = 0; i < 3; ++i) + for (auto i = 0; i < 3; ++i) { - for (int j = 0; j < 4; ++j) - for (unsigned int k = 0; k < 2; ++k) + for (auto j = 0; j < 4; ++j) + for (auto k = 0; k < 2; ++k) arr[i][j][k] = 8 * i + 2 * j + k; } @@ -1098,11 +1099,11 @@ SUITE(array_view_tests) TEST(dynamic_strided_array_view_section_iteration_3d) { - unsigned int height = 12, width = 2; - unsigned int size = height * width; + auto height = 12, width = 2; + auto size = height * width; auto arr = new int[size]; - for (int unsigned i = 0; i < size; ++i) + for (auto i = 0; i < size; ++i) { arr[i] = i; } @@ -1137,7 +1138,7 @@ SUITE(array_view_tests) X arr[4] = { { 0,1,2 },{ 3,4,5 },{ 6,7,8 },{ 9,10,11 } }; - auto s = sizeof(int) / sizeof(byte); + int s = sizeof(int) / sizeof(byte); auto d2 = 3 * s; auto d1 = sizeof(int) * 12 / d2; @@ -1179,152 +1180,6 @@ SUITE(array_view_tests) } - template - index Convert(index index) - { - return{ index }; - } - - TEST(DomainConverters) - { - // to smaller - { - index<2, int> int_index{ 0,1 }; - index<2, short> short_index{ int_index }; - - CHECK(short_index[0] == 0); - CHECK(short_index[1] == 1); - } - - // to smaller (failure) - { - index<2, int> big_int_index{ std::numeric_limits::max(), 1 }; - CHECK_THROW((Convert<2,int, short int>(big_int_index)), fail_fast); - } - - // to same, sign mismatch - { - index<2, int> int_index{ 0,1 }; - index<2, unsigned int> uint_index{ int_index }; - - CHECK(uint_index[0] == 0); - CHECK(uint_index[1] == 1); - } - - // to same, sign mismatch, reversed - { - index<2, unsigned int> uint_index{ 0,1 }; - index<2, int> int_index{ uint_index }; - - CHECK(int_index[0] == 0); - CHECK(int_index[1] == 1); - } - - // to smaller, sign mismatch - { - index<2, int> int_index{ 0,1 }; - index<2, unsigned short> ushort_index{ int_index }; - - CHECK(ushort_index[0] == 0); - CHECK(ushort_index[1] == 1); - } - - // to bigger - { - index<2, int> int_index{ 0,1 }; - index<2, long long> longlong_index{ int_index }; - - CHECK(longlong_index[0] == 0); - CHECK(longlong_index[1] == 1); - } - - // to bigger with max index - { - index<2, int> big_int_index{ std::numeric_limits::max(), 1 }; - index<2, long long> longlong_index{ big_int_index }; - - CHECK(longlong_index[0] == std::numeric_limits::max()); - CHECK(longlong_index[1] == 1); - } - - // to bigger, sign mismatch - { - index<2, int> int_index{ 0,1 }; - index<2, unsigned long long> ulonglong_index{ int_index }; - - CHECK(ulonglong_index[0] == 0); - CHECK(ulonglong_index[1] == 1); - } - - } - - TEST(DomainConvertersRank1) - { - // to smaller - { - index<1, int> int_index{ 0 }; - index<1, short> short_index{ int_index }; - - CHECK(short_index[0] == 0); - } - - // to smaller (failure) - { - index<1, int> big_int_index{ std::numeric_limits::max() }; - - CHECK_THROW((Convert<1, int, short int>(big_int_index)), fail_fast); - } - - // to same, sign mismatch - { - index<1, int> int_index{ 0 }; - index<1, unsigned int> uint_index{ int_index }; - - CHECK(uint_index[0] == 0); - } - - // to same, sign mismatch, reversed - { - index<1, unsigned int> uint_index{ 0 }; - index<1, int> int_index{ uint_index }; - - CHECK(int_index[0] == 0); - } - - // to smaller, sign mismatch - { - index<1, int> int_index{ 0 }; - index<1, unsigned short> ushort_index{ int_index }; - - CHECK(ushort_index[0] == 0); - } - - // to bigger - { - index<1, int> int_index{ 0 }; - index<1, long long> longlong_index{ int_index }; - - CHECK(longlong_index[0] == 0); - } - - // to bigger with max index - { - index<1, int> big_int_index{ std::numeric_limits::max() }; - index<1, long long> longlong_index{ big_int_index }; - - CHECK(longlong_index[0] == std::numeric_limits::max()); - } - - // to bigger, sign mismatch - { - index<1, int> int_index{ 0 }; - index<1, unsigned long long> ulonglong_index{ int_index }; - - CHECK(ulonglong_index[0] == 0); - } - - } - TEST(constructors) { array_view av(nullptr); @@ -1370,7 +1225,7 @@ SUITE(array_view_tests) int arr[] = {3, 4, 5}; av1 = arr; - array_view, dynamic_range> av2; + array_view av2; av2 = av1; } @@ -1380,21 +1235,21 @@ SUITE(array_view_tests) { array_view av = arr; - CHECK((av.first<2>().bounds() == static_bounds())); + CHECK((av.first<2>().bounds() == static_bounds<2>())); CHECK(av.first<2>().length() == 2); CHECK(av.first(2).length() == 2); } { array_view av = arr; - CHECK((av.first<0>().bounds() == static_bounds())); + CHECK((av.first<0>().bounds() == static_bounds<0>())); CHECK(av.first<0>().length() == 0); CHECK(av.first(0).length() == 0); } { array_view av = arr; - CHECK((av.first<5>().bounds() == static_bounds())); + CHECK((av.first<5>().bounds() == static_bounds<5>())); CHECK(av.first<5>().length() == 5); CHECK(av.first(5).length() == 5); } @@ -1402,7 +1257,7 @@ SUITE(array_view_tests) { array_view av = arr; #ifdef CONFIRM_COMPILATION_ERRORS - CHECK(av.first<6>().bounds() == static_bounds()); + CHECK(av.first<6>().bounds() == static_bounds<6>()); CHECK(av.first<6>().length() == 6); #endif CHECK_THROW(av.first(6).length(), fail_fast); @@ -1410,7 +1265,7 @@ SUITE(array_view_tests) { array_view av; - CHECK((av.first<0>().bounds() == static_bounds())); + CHECK((av.first<0>().bounds() == static_bounds<0>())); CHECK(av.first<0>().length() == 0); CHECK(av.first(0).length() == 0); } @@ -1422,21 +1277,21 @@ SUITE(array_view_tests) { array_view av = arr; - CHECK((av.last<2>().bounds() == static_bounds())); + CHECK((av.last<2>().bounds() == static_bounds<2>())); CHECK(av.last<2>().length() == 2); CHECK(av.last(2).length() == 2); } { array_view av = arr; - CHECK((av.last<0>().bounds() == static_bounds())); + CHECK((av.last<0>().bounds() == static_bounds<0>())); CHECK(av.last<0>().length() == 0); CHECK(av.last(0).length() == 0); } { array_view av = arr; - CHECK((av.last<5>().bounds() == static_bounds())); + CHECK((av.last<5>().bounds() == static_bounds<5>())); CHECK(av.last<5>().length() == 5); CHECK(av.last(5).length() == 5); } @@ -1445,7 +1300,7 @@ SUITE(array_view_tests) { array_view av = arr; #ifdef CONFIRM_COMPILATION_ERRORS - CHECK((av.last<6>().bounds() == static_bounds())); + CHECK((av.last<6>().bounds() == static_bounds<6>())); CHECK(av.last<6>().length() == 6); #endif CHECK_THROW(av.last(6).length(), fail_fast); @@ -1453,7 +1308,7 @@ SUITE(array_view_tests) { array_view av; - CHECK((av.last<0>().bounds() == static_bounds())); + CHECK((av.last<0>().bounds() == static_bounds<0>())); CHECK(av.last<0>().length() == 0); CHECK(av.last(0).length() == 0); } @@ -1462,12 +1317,12 @@ SUITE(array_view_tests) TEST(custmized_array_view_size) { double (*arr)[3][4] = new double[100][3][4]; - array_view, dynamic_range, 3, 4> av1(arr, (char)10); + array_view av1(arr, 10); struct EffectiveStructure { double* v1; - char v2; + ptrdiff_t v2; }; CHECK(sizeof(av1) == sizeof(EffectiveStructure)); @@ -1483,7 +1338,7 @@ SUITE(array_view_tests) { array_view av = arr; - CHECK((av.sub<2,2>().bounds() == static_bounds())); + CHECK((av.sub<2,2>().bounds() == static_bounds<2>())); CHECK((av.sub<2,2>().length() == 2)); CHECK(av.sub(2,2).length() == 2); CHECK(av.sub(2,3).length() == 3); @@ -1492,14 +1347,14 @@ SUITE(array_view_tests) { array_view av = arr; - CHECK((av.sub<0,0>().bounds() == static_bounds())); + CHECK((av.sub<0,0>().bounds() == static_bounds<0>())); CHECK((av.sub<0,0>().length() == 0)); CHECK(av.sub(0,0).length() == 0); } { array_view av = arr; - CHECK((av.sub<0,5>().bounds() == static_bounds())); + CHECK((av.sub<0,5>().bounds() == static_bounds<5>())); CHECK((av.sub<0,5>().length() == 5)); CHECK(av.sub(0,5).length() == 5); CHECK_THROW(av.sub(0,6).length(), fail_fast); @@ -1508,7 +1363,7 @@ SUITE(array_view_tests) { array_view av = arr; - CHECK((av.sub<5,0>().bounds() == static_bounds())); + CHECK((av.sub<5,0>().bounds() == static_bounds<0>())); CHECK((av.sub<5, 0>().length() == 0)); CHECK(av.sub(5,0).length() == 0); CHECK_THROW(av.sub(6,0).length(), fail_fast); @@ -1516,7 +1371,7 @@ SUITE(array_view_tests) { array_view av; - CHECK((av.sub<0,0>().bounds() == static_bounds())); + CHECK((av.sub<0,0>().bounds() == static_bounds<0>())); CHECK((av.sub<0,0>().length() == 0)); CHECK(av.sub(0,0).length() == 0); CHECK_THROW((av.sub<1,0>().length()), fail_fast); @@ -1564,7 +1419,7 @@ SUITE(array_view_tests) void AssertContentsMatch(T a1, U a2) { CHECK(a1.length() == a2.length()); - for (size_t i = 0; i < a1.length(); ++i) + for (auto i = 0; i < a1.length(); ++i) CHECK(a1[i] == a2[i]); } @@ -1726,7 +1581,7 @@ SUITE(array_view_tests) CHECK(av1 == av2); - array_view, 20> av3 = av1.as_array_view(dim<>(20)); + array_view av3 = av1.as_array_view(dim<>(20)); CHECK(av3 == av2 && av3 == av1); }