From 9523c1842e1c919aff9eac38111fc58b99e3b0c0 Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Wed, 16 Nov 2016 10:15:04 -0800 Subject: [PATCH] Fix template pack expansion bug in multi_span. * Fix issue #333 by moving a parenthesis. * Added test to prove fix is good. --- gsl/multi_span | 2 +- tests/multi_span_tests.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gsl/multi_span b/gsl/multi_span index d91f02a..479b074 100644 --- a/gsl/multi_span +++ b/gsl/multi_span @@ -1488,7 +1488,7 @@ public: constexpr reference operator()(FirstIndex index, OtherIndices... indices) { index_type idx = {narrow_cast(index), - narrow_cast(indices...)}; + narrow_cast(indices)...}; return this->operator[](idx); } diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp index 8dbe151..0c17944 100644 --- a/tests/multi_span_tests.cpp +++ b/tests/multi_span_tests.cpp @@ -941,8 +941,17 @@ SUITE(multi_span_tests) { multi_span 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 s = arr3d; + CHECK(s(0, 0, 0) == 1); + CHECK(s(1, 1, 1) == 8); + } } TEST(comparison_operators)