stlab / libraries

ASL libraries will be migrated here in the stlab namespace, new libraries will be created here.
https://stlab.cc
Boost Software License 1.0
660 stars 65 forks source link

Compilation fix for `future::then(executor, f)` #520

Closed fosterbrereton closed 1 year ago

fosterbrereton commented 1 year ago

The implementation of future::then(E&& executor, F&& f) constructs a lambda that is not mutable, but then calls std::move(_f). On Xcode 13.4.1, this causes a compilation error because the lambda is const. Making the lambda mutable resolves the issue.

FelixPetriconi commented 1 year ago

Well, actually std::move() casts _f to an r-value and then returns the result of the call to _f();

Was this triggered with one of our tests, or because of a special callable that you have passed to it?

I do not want to exclude that we have a bug here. I would like to understand why we did not find this with our tests.

fosterbrereton commented 1 year ago

You know, I had hit a compilation issue when working on a class that depended on this code, and adding mutable made the compiler happy. I have since removed these changes and recompiled the code to try and find a specific unit test that I could add. But the error has disappeared. You can disregard this PR for now, but if it happens again, I'll let you know.