mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Fix #54 : Verify that coordinate_facade::value_type is unsigned. Also add additional assert at source of signed type.
This commit is contained in:
parent
8ae77b1fd5
commit
b324019c24
@ -75,6 +75,7 @@ namespace details
|
|||||||
class coordinate_facade
|
class coordinate_facade
|
||||||
{
|
{
|
||||||
static_assert(std::is_integral<ValueType>::value
|
static_assert(std::is_integral<ValueType>::value
|
||||||
|
&& !std::is_signed<ValueType>::value
|
||||||
&& sizeof(ValueType) <= sizeof(size_t), "ValueType must be unsigned integral type!");
|
&& sizeof(ValueType) <= sizeof(size_t), "ValueType must be unsigned integral type!");
|
||||||
static_assert(Rank > 0, "Rank must be greater than 0!");
|
static_assert(Rank > 0, "Rank must be greater than 0!");
|
||||||
|
|
||||||
@ -1629,6 +1630,10 @@ namespace details
|
|||||||
template <typename ValueType, typename SizeType>
|
template <typename ValueType, typename SizeType>
|
||||||
struct array_view_options
|
struct array_view_options
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_integral<SizeType>::value
|
||||||
|
&& !std::is_signed<SizeType>::value
|
||||||
|
&& sizeof(SizeType) <= sizeof(size_t), "size_type must be unsigned integral type!");
|
||||||
|
|
||||||
struct array_view_traits
|
struct array_view_traits
|
||||||
{
|
{
|
||||||
using value_type = ValueType;
|
using value_type = ValueType;
|
||||||
|
@ -1305,7 +1305,7 @@ SUITE(array_view_tests)
|
|||||||
TEST(custmized_array_view_size)
|
TEST(custmized_array_view_size)
|
||||||
{
|
{
|
||||||
double (*arr)[3][4] = new double[100][3][4];
|
double (*arr)[3][4] = new double[100][3][4];
|
||||||
array_view<array_view_options<double, char>, dynamic_range, 3, 4> av1(arr, (char)10);
|
array_view<array_view_options<double, unsigned char>, dynamic_range, 3, 4> av1(arr, (char)10);
|
||||||
|
|
||||||
struct EffectiveStructure
|
struct EffectiveStructure
|
||||||
{
|
{
|
||||||
@ -1569,7 +1569,7 @@ SUITE(array_view_tests)
|
|||||||
|
|
||||||
CHECK(av1 == av2);
|
CHECK(av1 == av2);
|
||||||
|
|
||||||
array_view<array_view_options<int, char>, 20> av3 = av1.as_array_view(dim<>(20));
|
array_view<array_view_options<int, unsigned char>, 20> av3 = av1.as_array_view(dim<>(20));
|
||||||
CHECK(av3 == av2 && av3 == av1);
|
CHECK(av3 == av2 && av3 == av1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user