1 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unused-value -std=c++17
2 // expected-no-diagnostics
5 template <int num
> int return_num() { return num
; }
7 template <typename lambda
> struct lambda_wrapper
{
9 lambda_wrapper(lambda
& outer_lambda
) : outer_lambda(outer_lambda
) {}
10 template <typename T
> auto operator+(T t
) { outer_lambda(t
); return 1; }
13 template <int... nums
, typename lambda
>
14 void bw(lambda
& outer_lambda
) {
15 (lambda_wrapper(outer_lambda
) + ... + return_num
<nums
>());
18 template <typename lambda
> auto check_return_type(lambda inner_lambda
) {
19 using inner_lambda_return_type
= decltype(inner_lambda(5));
23 auto outer_lambda
= [](auto param
) {
24 auto inner_lambda
= [](auto o
) -> decltype(param
) {};
25 check_return_type(inner_lambda
);
27 bw
<1,2>(outer_lambda
);
34 template <typename lambda
>
35 auto run_lambda_with_zero(lambda l
) {
38 template <typename
... Ts
, typename lambda
>
39 void run_lambda_once_per_type(lambda l
) {
40 ((Ts
{}, run_lambda_with_zero(l
)), ...);
42 template <typename
> void inner_function() {
44 [](auto param
) -> decltype(c
) { return param
; }(0);
47 auto x
= [](auto) -> void { inner_function
<int>(); };
48 run_lambda_once_per_type
<int>(x
);