From caa2605a283c784ebc6f83778c04a9d841c954f9 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 21 Mar 2018 18:25:22 -0700 Subject: Don't capture unnecessary or unused variables --- test/core/gprpp/inlined_vector_test.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'test/core/gprpp/inlined_vector_test.cc') diff --git a/test/core/gprpp/inlined_vector_test.cc b/test/core/gprpp/inlined_vector_test.cc index b900afaf3d..2a357420f3 100644 --- a/test/core/gprpp/inlined_vector_test.cc +++ b/test/core/gprpp/inlined_vector_test.cc @@ -87,14 +87,17 @@ TEST(InlinedVectorTest, ClearAndRepopulate) { } TEST(InlinedVectorTest, ConstIndexOperator) { - const int kNumElements = 10; + constexpr int kNumElements = 10; InlinedVector v; EXPECT_EQ(0UL, v.size()); for (int i = 0; i < kNumElements; ++i) { v.push_back(i); EXPECT_EQ(i + 1UL, v.size()); } - auto const_func = [kNumElements](const InlinedVector& v) { + // The following lambda function is exceptionally allowed to use an anonymous + // capture due to the erroneous behavior of the MSVC compiler, that refuses to + // capture the kNumElements constexpr, something allowed by the standard. + auto const_func = [&](const InlinedVector& v) { for (int i = 0; i < kNumElements; ++i) { EXPECT_EQ(i, v[i]); } -- cgit v1.2.3