Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If you pass a lambda function by copy what actually gets copied?

Tags:

c++

If you pass a lambda function by copy in c++ what actually gets copied?

Is it just a pointer to the lambda?

Or does the whole capture list get copied as well?

like image 247
Lord Nikon Avatar asked May 29 '26 12:05

Lord Nikon


1 Answers

Lambda functions are usually realized as compiler generated functor classes.

Or does the whole capture list get copied as well?

The captures go to the class internal data members, and those will be copied.

like image 105
πάντα ῥεῖ Avatar answered Jun 04 '26 16:06

πάντα ῥεῖ