131
|
1 // P0624R2
|
|
2 // { dg-do compile { target c++11 } }
|
|
3
|
|
4 #if __cplusplus >= 201402L
|
|
5 #define A auto
|
|
6 #else
|
|
7 #define A int
|
|
8 #endif
|
|
9
|
|
10 void
|
|
11 f1 ()
|
|
12 {
|
|
13 auto greater = [](A x, A y) { return x > y; }; // { dg-message "a lambda closure type has a deleted (default constructor|copy assignment operator)" "" { target c++17_down } }
|
|
14 decltype (greater) gt; // { dg-error "use of deleted function" "" { target c++17_down } }
|
|
15 gt = greater; // { dg-error "use of deleted function" "" { target c++17_down } }
|
|
16 }
|
|
17
|
|
18 void
|
|
19 f2 ()
|
|
20 {
|
|
21 auto greater = [&](A x, A y) { return x > y; }; // { dg-message "a lambda closure type has a deleted (default constructor|copy assignment operator)" }
|
|
22 decltype (greater) gt; // { dg-error "use of deleted function" }
|
|
23 gt = greater; // { dg-error "use of deleted function" }
|
|
24 }
|
|
25
|
|
26 void
|
|
27 f3 ()
|
|
28 {
|
|
29 auto greater = [=](A x, A y) { return x > y; }; // { dg-message "a lambda closure type has a deleted (default constructor|copy assignment operator)" }
|
|
30 decltype (greater) gt; // { dg-error "use of deleted function" }
|
|
31 gt = greater; // { dg-error "use of deleted function" }
|
|
32 }
|
|
33
|
|
34 void
|
|
35 f4 (int i)
|
|
36 {
|
|
37 auto greater = [i](A x, A y) { return x > y; }; // { dg-message "a lambda closure type has a deleted (default constructor|copy assignment operator)" }
|
|
38 decltype (greater) gt; // { dg-error "use of deleted function" }
|
|
39 gt = greater; // { dg-error "use of deleted function" }
|
|
40 }
|
|
41
|
|
42 #if __cplusplus > 201703L
|
|
43 void
|
|
44 f5 ()
|
|
45 {
|
|
46 auto greater = [](auto x, auto y) constexpr { return x > y; };
|
|
47 decltype (greater) gt;
|
|
48 static_assert (!gt (1, 2));
|
|
49 static_assert (gt (4, 3));
|
|
50 static_assert (!gt (3.5, 3.75));
|
|
51 static_assert (gt (3.5, 3.25));
|
|
52 gt = greater;
|
|
53 static_assert (!gt (1, 2));
|
|
54 static_assert (gt (4, 3));
|
|
55 static_assert (!gt (3.5, 3.75));
|
|
56 static_assert (gt (3.5, 3.25));
|
|
57 }
|
|
58 #endif
|