Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advanced C++ multiple parentheses [duplicate]

Tags:

c++

lambda

I'm reviewing a sample program code and found this line:

auto prerequisite = task<void>([](){});

What is the meaning of those combined parentheses ([](){})

I'm a cpp programmer but do not know advance cpp (c11+) which this Microsoft example is written at. Googling didn't help, and I don't know the name of those operators.

like image 601
hamavreg Avatar asked Jan 31 '19 10:01

hamavreg


1 Answers

[](){} is a lambda expression that creates a function object that has non-zero size and does nothing.

This is probably to avoid checking whether prerequisite is valid/exists - it is always valid, but may do nothing.

like image 75
Maxim Egorushkin Avatar answered Oct 17 '22 19:10

Maxim Egorushkin