There are no designers. This code works due to the merging of three functions new in C ++ 17:
- Conclusion of a template parameter for designers ( P0091 ).
- Implement Initialization Extension ( P0017 )
- Modernization of use of declarations ( P0195 ).
What happens on this line:
C c { []{}, [](int){} };
is that we first use the output of template parameter (1) to infer that c really has type C<__lambda1, __lambda2> . This is done using a deduction guide.
Further, since C<__lambda1, __lambda2> is a collection (due to (2) relaxation of the restrictions of the base class - you are correct that you are not considered an aggregate in C ++ 11/14), we can use the initialization of the aggregate to initialize This. We do not use a constructor. The way aggregate initialization now works with base classes is that we just need to initialize the bases from left to right. So, the first expression ( []{} ) is used to initialize the first base class ( __lambda1 ), and the second expression ( [](int){} ) is used to initialize the second base class ( __lambda2 ).
Finally, calling c(3) works because (3) allowed you to simply write
using T::operator()...;
which includes lambdas call statements in area c , where overload resolution might work as expected. As a result, we call the __lambda2 call __lambda2 , which does nothing.
Barry source share