Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22085

How does the lambda macro create a lambda?

$
0
0

I found this piece of code on GitHub but didn't quite understand it:

#define lambda(ret_type, _body) ({ ret_type _ _body _; })

Then:

int (*max)(int, int) = lambda(int,
                             (int x, int y) {
                                 return x > y ? x : y;
                             });

int max_value = max(1, 2);
// max_value is 2

What are the underscores doing inside the #define and how does it return a function pointer?


Viewing all articles
Browse latest Browse all 22085

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>