Skip to content

Commit

Permalink
Fix deprecated this capture in wangle/service/Service.h
Browse files Browse the repository at this point in the history
Summary:
In the future LLVM will require that lambdas capture `this` explicitly. `-Wdeprecated-this-capture` checks for and enforces this now.

This diff adds an explicit `this` capture to a lambda to fix an issue that presents similarly to this:
```
   -> fbcode/path/to/my_file.cpp:66:47: error: implicit capture of 'this' with a capture default of '=' is deprecated [-Werror,-
Wdeprecated-this-capture]
   ->           detail::createIOWorkerProvider(evb, requestsRegistry_);
   ->                                               ^
   -> fbcode/path/to/my_file.cpp:61:30: note: add an explicit capture of 'this' to capture '*this' by reference
   ->   evb->runInEventBaseThread([=, self_weak = std::move(self_weak)]() {
   ->                              ^
   ->                               , this
```

Reviewed By: meyering

Differential Revision: D52279199

fbshipit-source-id: 05572dce87494ed24b0deece742da74e30b04de8
  • Loading branch information
r-barnes authored and facebook-github-bot committed Dec 19, 2023
1 parent cd08966 commit d81d13e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion wangle/service/Service.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class FactoryToService : public Service<Req, Resp> {
folly::Future<Resp> operator()(Req request) override {
DCHECK(factory_);
return ((*factory_)(nullptr))
.thenValue([=](std::shared_ptr<Service<Req, Resp>> service) {
.thenValue([=, this](std::shared_ptr<Service<Req, Resp>> service) {
return (*service)(std::move(request)).ensure([this]() {
this->close();
});
Expand Down

0 comments on commit d81d13e

Please sign in to comment.