From fdf864347150a108a33a467bc7ba3efd1ad78b2f Mon Sep 17 00:00:00 2001 From: Anna Gringauze Date: Wed, 14 Oct 2015 10:46:22 -0700 Subject: [PATCH] Fixes for gcc --- include/array_view.h | 36 ++++++++++++++++++------------------ tests/array_view_tests.cpp | 13 +++++++------ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/include/array_view.h b/include/array_view.h index 98bbadf..3502076 100644 --- a/include/array_view.h +++ b/include/array_view.h @@ -686,6 +686,17 @@ namespace details { return TypeListIndexer(obj); } + + 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) + { + ret[i] = other[i + 1]; + } + return ret; + } } template @@ -790,7 +801,7 @@ public: constexpr index_type index_bounds() const noexcept { - size_type extents[rank]; + size_type extents[rank] = {}; m_ranges.serialize(extents); return{ extents }; } @@ -826,11 +837,11 @@ class strided_bounds public: static const size_t rank = Rank; - using reference = typename SizeType&; - using const_reference = typename const SizeType&; - using size_type = typename SizeType; - using difference_type = typename SizeType; - using value_type = typename SizeType; + 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 iterator = bounds_iterator; using const_iterator = bounds_iterator; @@ -1254,7 +1265,7 @@ namespace details constexpr std::enable_if_t::value, typename Bounds::index_type> make_stride(const Bounds& bnd) noexcept { auto extents = bnd.index_bounds(); - Bounds::size_type stride[Bounds::rank]; + typename Bounds::size_type stride[Bounds::rank] = {}; stride[Bounds::rank - 1] = 1; for (size_t i = 1; i < Bounds::rank; ++i) @@ -1264,17 +1275,6 @@ namespace details return{ stride }; } - 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) - { - ret[i] = other[i + 1]; - } - return ret; - } - template void verifyBoundsReshape(const BoundsSrc &src, const BoundsDest &dest) { diff --git a/tests/array_view_tests.cpp b/tests/array_view_tests.cpp index a56d0f2..f84e908 100644 --- a/tests/array_view_tests.cpp +++ b/tests/array_view_tests.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1197,7 +1198,7 @@ SUITE(array_view_tests) // to smaller (failure) { - index<2, int> big_int_index{ INT_MAX, 1 }; + index<2, int> big_int_index{ std::numeric_limits::max(), 1 }; CHECK_THROW((Convert<2,int, short int>(big_int_index)), fail_fast); } @@ -1239,10 +1240,10 @@ SUITE(array_view_tests) // to bigger with max index { - index<2, int> big_int_index{ INT_MAX, 1 }; + index<2, int> big_int_index{ std::numeric_limits::max(), 1 }; index<2, long long> longlong_index{ big_int_index }; - CHECK(longlong_index[0] == INT_MAX); + CHECK(longlong_index[0] == std::numeric_limits::max()); CHECK(longlong_index[1] == 1); } @@ -1269,7 +1270,7 @@ SUITE(array_view_tests) // to smaller (failure) { - index<1, int> big_int_index{ INT_MAX }; + index<1, int> big_int_index{ std::numeric_limits::max() }; CHECK_THROW((Convert<1, int, short int>(big_int_index)), fail_fast); } @@ -1308,10 +1309,10 @@ SUITE(array_view_tests) // to bigger with max index { - index<1, int> big_int_index{ INT_MAX }; + index<1, int> big_int_index{ std::numeric_limits::max() }; index<1, long long> longlong_index{ big_int_index }; - CHECK(longlong_index[0] == INT_MAX); + CHECK(longlong_index[0] == std::numeric_limits::max()); } // to bigger, sign mismatch