Fixes for gcc

This commit is contained in:
Anna Gringauze 2015-10-14 10:46:22 -07:00
parent 546f8cc130
commit fdf8643471
2 changed files with 25 additions and 24 deletions

View File

@ -686,6 +686,17 @@ namespace details
{ {
return TypeListIndexer<TypeChain>(obj); return TypeListIndexer<TypeChain>(obj);
} }
template <size_t Rank, typename ValueType, bool Enabled = (Rank > 1), typename Ret = std::enable_if_t<Enabled, index<Rank - 1, ValueType>>>
constexpr Ret shift_left(const index<Rank, ValueType>& other) noexcept
{
Ret ret;
for (size_t i = 0; i < Rank - 1; ++i)
{
ret[i] = other[i + 1];
}
return ret;
}
} }
template <typename IndexType> template <typename IndexType>
@ -790,7 +801,7 @@ public:
constexpr index_type index_bounds() const noexcept constexpr index_type index_bounds() const noexcept
{ {
size_type extents[rank]; size_type extents[rank] = {};
m_ranges.serialize(extents); m_ranges.serialize(extents);
return{ extents }; return{ extents };
} }
@ -826,11 +837,11 @@ class strided_bounds
public: public:
static const size_t rank = Rank; static const size_t rank = Rank;
using reference = typename SizeType&; using reference = SizeType&;
using const_reference = typename const SizeType&; using const_reference = const SizeType&;
using size_type = typename SizeType; using size_type = SizeType;
using difference_type = typename SizeType; using difference_type = SizeType;
using value_type = typename SizeType; using value_type = SizeType;
using index_type = index<rank, size_type>; using index_type = index<rank, size_type>;
using iterator = bounds_iterator<index_type>; using iterator = bounds_iterator<index_type>;
using const_iterator = bounds_iterator<index_type>; using const_iterator = bounds_iterator<index_type>;
@ -1254,7 +1265,7 @@ namespace details
constexpr std::enable_if_t<std::is_same<typename Bounds::mapping_type, contiguous_mapping_tag>::value, typename Bounds::index_type> make_stride(const Bounds& bnd) noexcept constexpr std::enable_if_t<std::is_same<typename Bounds::mapping_type, contiguous_mapping_tag>::value, typename Bounds::index_type> make_stride(const Bounds& bnd) noexcept
{ {
auto extents = bnd.index_bounds(); auto extents = bnd.index_bounds();
Bounds::size_type stride[Bounds::rank]; typename Bounds::size_type stride[Bounds::rank] = {};
stride[Bounds::rank - 1] = 1; stride[Bounds::rank - 1] = 1;
for (size_t i = 1; i < Bounds::rank; ++i) for (size_t i = 1; i < Bounds::rank; ++i)
@ -1264,17 +1275,6 @@ namespace details
return{ stride }; return{ stride };
} }
template <size_t Rank, typename ValueType, bool Enabled = (Rank > 1), typename Ret = std::enable_if_t<Enabled, index<Rank-1, ValueType>>>
constexpr Ret shift_left(const index<Rank, ValueType>& other) noexcept
{
Ret ret;
for (size_t i = 0; i < Rank - 1; ++i)
{
ret[i] = other[i + 1];
}
return ret;
}
template <typename BoundsSrc, typename BoundsDest> template <typename BoundsSrc, typename BoundsDest>
void verifyBoundsReshape(const BoundsSrc &src, const BoundsDest &dest) void verifyBoundsReshape(const BoundsSrc &src, const BoundsDest &dest)
{ {

View File

@ -17,6 +17,7 @@
#include <UnitTest++/UnitTest++.h> #include <UnitTest++/UnitTest++.h>
#include <array_view.h> #include <array_view.h>
#include <numeric> #include <numeric>
#include <limits>
#include <array> #include <array>
#include <string> #include <string>
#include <vector> #include <vector>
@ -1197,7 +1198,7 @@ SUITE(array_view_tests)
// to smaller (failure) // to smaller (failure)
{ {
index<2, int> big_int_index{ INT_MAX, 1 }; index<2, int> big_int_index{ std::numeric_limits<int>::max(), 1 };
CHECK_THROW((Convert<2,int, short int>(big_int_index)), fail_fast); 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 // to bigger with max index
{ {
index<2, int> big_int_index{ INT_MAX, 1 }; index<2, int> big_int_index{ std::numeric_limits<int>::max(), 1 };
index<2, long long> longlong_index{ big_int_index }; index<2, long long> longlong_index{ big_int_index };
CHECK(longlong_index[0] == INT_MAX); CHECK(longlong_index[0] == std::numeric_limits<int>::max());
CHECK(longlong_index[1] == 1); CHECK(longlong_index[1] == 1);
} }
@ -1269,7 +1270,7 @@ SUITE(array_view_tests)
// to smaller (failure) // to smaller (failure)
{ {
index<1, int> big_int_index{ INT_MAX }; index<1, int> big_int_index{ std::numeric_limits<int>::max() };
CHECK_THROW((Convert<1, int, short int>(big_int_index)), fail_fast); 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 // to bigger with max index
{ {
index<1, int> big_int_index{ INT_MAX }; index<1, int> big_int_index{ std::numeric_limits<int>::max() };
index<1, long long> longlong_index{ big_int_index }; index<1, long long> longlong_index{ big_int_index };
CHECK(longlong_index[0] == INT_MAX); CHECK(longlong_index[0] == std::numeric_limits<int>::max());
} }
// to bigger, sign mismatch // to bigger, sign mismatch