capture-list Questions
4
Solved
When moving std::unique_ptr into the lambda, it is not possible to call reset() on it, because it seems to be const then:
error C2662: void std::unique_ptr<int,std::default_delete<_Ty>>...
Dental asked 4/7, 2019 at 15:37
2
Solved
With closures I usually append [weak self] onto my capture list and then do a null check on self:
func myInstanceMethod()
{
let myClosure =
{
[weak self] (result : Bool) in
if let this = self
...
Nyctalopia asked 30/10, 2014 at 23:18
0
We've totally forgotten to capture self and its properties when referencing it within a closure. (Note: the compiler didn't warn us.) Now our application is full with strong reference cycles. To fi...
Sepoy asked 27/2, 2018 at 17:22
1
Here I have some examples for closure strong reference cycles.
If I assign a closure to a stored property, I can use a closure capture list to make the captured reference unowned/weak.
But if I ass...
Escort asked 6/10, 2016 at 14:44
1
© 2022 - 2024 — McMap. All rights reserved.