Skip to content

Commit 7a010b5

Browse files
committed
fixed -Wdeprecated-this-capture Clang C++20 warning [skip ci]
example: ``` /home/user/CLionProjects/cppcheck/lib/pathmatch.cpp:37:37: warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture] 37 | return match(pattern, path, mBasepath, mode, mSyntax); | ^ /home/user/CLionProjects/cppcheck/lib/pathmatch.cpp:36:63: note: add an explicit capture of 'this' to capture '*this' by reference 36 | return std::any_of(mPatterns.cbegin(), mPatterns.cend(), [=] (const std::string &pattern) { | ^ | , this ```
1 parent 41fa8a9 commit 7a010b5

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

gui/resultstree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,15 +702,15 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
702702
{
703703
auto *action = new QAction(tr("No tag"), tagMenu);
704704
tagMenu->addAction(action);
705-
connect(action, &QAction::triggered, [=]() {
705+
connect(action, &QAction::triggered, [=, this]() {
706706
tagSelectedItems(QString());
707707
});
708708
}
709709

710710
for (const QString& tagstr : currentProject->getTags()) {
711711
auto *action = new QAction(tagstr, tagMenu);
712712
tagMenu->addAction(action);
713-
connect(action, &QAction::triggered, [=]() {
713+
connect(action, &QAction::triggered, [=, this]() {
714714
tagSelectedItems(tagstr);
715715
});
716716
}

lib/pathmatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PathMatch::PathMatch(std::vector<std::string> patterns, std::string basepath, Sy
3333

3434
bool PathMatch::match(const std::string &path, Filemode mode) const
3535
{
36-
return std::any_of(mPatterns.cbegin(), mPatterns.cend(), [=] (const std::string &pattern) {
36+
return std::any_of(mPatterns.cbegin(), mPatterns.cend(), [&] (const std::string &pattern) {
3737
return match(pattern, path, mBasepath, mode, mSyntax);
3838
});
3939
}

0 commit comments

Comments
 (0)