Skip to content

What happened to our mutable lambdas? #292

@aaronalbers

Description

@aaronalbers

This simple piece of code will no longer compile (tested with 1.5.1).

#include <iostream>

#include <stlab/concurrency/default_executor.hpp>
#include <stlab/concurrency/future.hpp>

int main() {
   auto func = [i = int{0}]() mutable {
      i++;
   };
   
   stlab::async(stlab::default_executor, [func = std::move(func)]() mutable {
      func();
      
      stlab::async(stlab::default_executor, [func = std::move(func)]() mutable {
         func();
      }).detach();
      
   }).detach();
   
   return 0;
}

When I tried to upgrade to the latest version of stlab I was surprised to find that all of my wrapper functions would no longer compile. I have periodic task wrappers that function in principle like the above code.

IMHO the fallout from #260 was much larger than it needed to be as we are still trying to get back functionality like with #287

For the time being I am stuck at version 1.4.1

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions