Skip to content

Commit c0a756a

Browse files
committed
COMP: Fix unused-lambda-capture statement
lambda capture 'n' is not required to be captured for this use [-Wunused-lambda-capture]
1 parent 408f57d commit c0a756a

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

Modules/Core/Common/test/itkImageBufferRangeGTest.cxx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ TEST(ImageBufferRange, IteratorsSupportRandomAccess)
664664

665665
{
666666
// Expression to be tested: 'r += n'
667-
difference_type const n = 3;
667+
constexpr difference_type n = 3;
668668

669669
r = initialIterator;
670-
const auto expectedResult = [&r, n] {
670+
const auto expectedResult = [&r](const difference_type n) {
671671
// Operational semantics, as specified by the C++11 Standard:
672672
difference_type m = n;
673673
if (m >= 0)
@@ -677,53 +677,53 @@ TEST(ImageBufferRange, IteratorsSupportRandomAccess)
677677
while (m++)
678678
--r;
679679
return r;
680-
}();
680+
}(n);
681681
r = initialIterator;
682682
auto && actualResult = r += n;
683683
EXPECT_EQ(actualResult, expectedResult);
684684
static_assert(std::is_same_v<decltype(actualResult), X &>, "Type of result 'r += n' tested");
685685
}
686686
{
687687
// Expressions to be tested: 'a + n' and 'n + a'
688-
difference_type const n = 3;
688+
constexpr difference_type n = 3;
689689

690690
static_assert(std::is_same_v<decltype(a + n), X>, "Return type tested");
691691
static_assert(std::is_same_v<decltype(n + a), X>, "Return type tested");
692692

693-
const auto expectedResult = [a, n] {
693+
const auto expectedResult = [a](const difference_type n) {
694694
// Operational semantics, as specified by the C++11 Standard:
695695
X tmp = a;
696696
return tmp += n;
697-
}();
697+
}(n);
698698

699699
EXPECT_EQ(a + n, expectedResult);
700700
EXPECT_TRUE(a + n == n + a);
701701
}
702702
{
703703
// Expression to be tested: 'r -= n'
704-
difference_type const n = 3;
704+
constexpr difference_type n = 3;
705705

706706
r = initialIterator;
707-
const auto expectedResult = [&r, n] {
707+
const auto expectedResult = [&r](const difference_type n) {
708708
// Operational semantics, as specified by the C++11 Standard:
709709
return r += -n;
710-
}();
710+
}(n);
711711
r = initialIterator;
712712
auto && actualResult = r -= n;
713713
EXPECT_EQ(actualResult, expectedResult);
714714
static_assert(std::is_same_v<decltype(actualResult), X &>, "Type of result 'r -= n' tested");
715715
}
716716
{
717717
// Expression to be tested: 'a - n'
718-
difference_type const n = -3;
718+
constexpr difference_type n = -3;
719719

720720
static_assert(std::is_same_v<decltype(a - n), X>, "Return type tested");
721721

722-
const auto expectedResult = [a, n] {
722+
const auto expectedResult = [a](const difference_type n) {
723723
// Operational semantics, as specified by the C++11 Standard:
724724
X tmp = a;
725725
return tmp -= n;
726-
}();
726+
}(n);
727727

728728
EXPECT_EQ(a - n, expectedResult);
729729
}
@@ -737,7 +737,7 @@ TEST(ImageBufferRange, IteratorsSupportRandomAccess)
737737
}
738738
{
739739
// Expression to be tested: 'a[n]'
740-
difference_type const n = 3;
740+
constexpr difference_type n = 3;
741741
static_assert(std::is_convertible_v<decltype(a[n]), reference>, "Return type tested");
742742
EXPECT_EQ(a[n], *(a + n));
743743
}

Modules/Core/Common/test/itkShapedImageNeighborhoodRangeGTest.cxx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -770,12 +770,12 @@ TEST(ShapedImageNeighborhoodRange, IteratorsSupportRandomAccess)
770770

771771
{
772772
// Expression to be tested: 'r += n'
773-
const difference_type n = 3;
773+
constexpr difference_type n = 3;
774774

775775
static_assert(std::is_same_v<decltype(r += n), X &>, "Return type tested");
776776

777777
r = initialIterator;
778-
const auto expectedResult = [&r, n] {
778+
const auto expectedResult = [&r](const difference_type n) {
779779
// Operational semantics, as specified by the C++11 Standard:
780780
difference_type m = n;
781781
if (m >= 0)
@@ -785,67 +785,67 @@ TEST(ShapedImageNeighborhoodRange, IteratorsSupportRandomAccess)
785785
while (m++)
786786
--r;
787787
return r;
788-
}();
788+
}(n);
789789
r = initialIterator;
790790
const auto actualResult = r += n;
791791
EXPECT_EQ(actualResult, expectedResult);
792792
}
793793
{
794794
// Expressions to be tested: 'a + n' and 'n + a'
795-
difference_type const n = 3;
795+
constexpr difference_type n = 3;
796796

797797
static_assert(std::is_same_v<decltype(a + n), X>, "Return type tested");
798798
static_assert(std::is_same_v<decltype(n + a), X>, "Return type tested");
799799

800-
const auto expectedResult = [a, n] {
800+
const auto expectedResult = [a](const difference_type n) {
801801
// Operational semantics, as specified by the C++11 Standard:
802802
X tmp = a;
803803
return tmp += n;
804-
}();
804+
}(n);
805805

806806
EXPECT_EQ(a + n, expectedResult);
807807
EXPECT_TRUE(a + n == n + a);
808808
}
809809
{
810810
// Expression to be tested: 'r -= n'
811-
difference_type const n = 3;
811+
constexpr difference_type n = 3;
812812

813813
static_assert(std::is_same_v<decltype(r -= n), X &>, "Return type tested");
814814

815815
r = initialIterator;
816-
const auto expectedResult = [&r, n] {
816+
const auto expectedResult = [&r](const difference_type n) {
817817
// Operational semantics, as specified by the C++11 Standard:
818818
return r += -n;
819-
}();
819+
}(n);
820820
r = initialIterator;
821821
const auto actualResult = r -= n;
822822
EXPECT_EQ(actualResult, expectedResult);
823823
}
824824
{
825825
// Expression to be tested: 'a - n'
826-
difference_type const n = -3;
826+
constexpr difference_type n = -3;
827827

828828
static_assert(std::is_same_v<decltype(a - n), X>, "Return type tested");
829829

830-
const auto expectedResult = [a, n] {
830+
const auto expectedResult = [a](const difference_type n) {
831831
// Operational semantics, as specified by the C++11 Standard:
832832
X tmp = a;
833833
return tmp -= n;
834-
}();
834+
}(n);
835835

836836
EXPECT_EQ(a - n, expectedResult);
837837
}
838838
{
839839
// Expression to be tested: 'b - a'
840840
static_assert(std::is_same_v<decltype(b - a), difference_type>, "Return type tested");
841841

842-
difference_type const n = b - a;
842+
const difference_type n = b - a;
843843
EXPECT_TRUE(a + n == b);
844844
EXPECT_TRUE(b == a + (b - a));
845845
}
846846
{
847847
// Expression to be tested: 'a[n]'
848-
const difference_type n = 3;
848+
constexpr difference_type n = 3;
849849
static_assert(std::is_convertible_v<decltype(a[n]), reference>, "Return type tested");
850850
EXPECT_EQ(a[n], *(a + n));
851851
}

0 commit comments

Comments
 (0)