Fix template pack expansion bug in multi_span.

* Fix issue #333 by moving a parenthesis.
* Added test to prove fix is good.
This commit is contained in:
Neil MacIntosh 2016-11-16 10:15:04 -08:00 committed by GitHub
parent bdcef948a5
commit 9523c1842e
2 changed files with 10 additions and 1 deletions

View File

@ -1488,7 +1488,7 @@ public:
constexpr reference operator()(FirstIndex index, OtherIndices... indices)
{
index_type idx = {narrow_cast<std::ptrdiff_t>(index),
narrow_cast<std::ptrdiff_t>(indices...)};
narrow_cast<std::ptrdiff_t>(indices)...};
return this->operator[](idx);
}

View File

@ -941,8 +941,17 @@ SUITE(multi_span_tests)
{
multi_span<int, 2, 3> s = arr2d;
CHECK(s(0, 0) == 1);
CHECK(s(0, 1) == 2);
CHECK(s(1, 2) == 6);
}
int arr3d[2][2][2] = {1, 2, 3, 4, 5, 6, 7, 8};
{
multi_span<int, 2, 2, 2> s = arr3d;
CHECK(s(0, 0, 0) == 1);
CHECK(s(1, 1, 1) == 8);
}
}
TEST(comparison_operators)