I am a bit confused by how std::function
is constructed at a given lambda. The constructor of std::function
is listed here. Which one is actually used to capture a lambda? Is it template< class F > function( F f );
? Looks like I can't construct std::function
with a lambda that captures non-copy-constructible objects. Why is this necessary for lambda capture?
// fu is an object of type std::future
std::function f = [future=std::move(fu)]() {...} // compile error
// foo is an object of type int
std::function f = [foo=std::move(foo)]() {...} // compile ok
Aucun commentaire:
Enregistrer un commentaire