mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Fixes for gcc
This commit is contained in:
parent
546f8cc130
commit
fdf8643471
@ -686,6 +686,17 @@ namespace details
|
||||
{
|
||||
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>
|
||||
@ -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<rank, size_type>;
|
||||
using 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
|
||||
{
|
||||
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 <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>
|
||||
void verifyBoundsReshape(const BoundsSrc &src, const BoundsDest &dest)
|
||||
{
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <UnitTest++/UnitTest++.h>
|
||||
#include <array_view.h>
|
||||
#include <numeric>
|
||||
#include <limits>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -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<int>::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<int>::max(), 1 };
|
||||
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);
|
||||
}
|
||||
|
||||
@ -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<int>::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<int>::max() };
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user