gcc/testsuite/g++.dg/cpp2a/consteval13.C
raw| 1 | // { dg-do compile } |
| 2 | // { dg-options "-std=c++2a" } |
| 3 | |
| 4 | consteval int bar () { return 42; } |
| 5 | consteval int baz () { return 1; } |
| 6 | typedef int (*fnptr) (); |
| 7 | consteval fnptr quux () { return bar; } |
| 8 | |
| 9 | void |
| 10 | foo () |
| 11 | { |
| 12 | auto qux = [] (fnptr a = quux ()) consteval { return a (); }; |
| 13 | constexpr auto c = qux (baz); |
| 14 | constexpr auto d = qux (bar); |
| 15 | static_assert (c == 1); |
| 16 | static_assert (d == 42); |
| 17 | } |