I'm looking for a way to capture by const&, or even const for that matter on a mutable lambda. Something like the syntax below. Is there a good way to do this?
#include <future>
#include <vector>
int main() {
std::promise<int> p;
const int N = 2;
std::vector<int> v = {1,2,3};
auto foo = [const& N, const& v, p = std::move(p)]() mutable {
v.push_back(4); // Should not compile
p.set_value(v[N]);
};
}