Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/constexpr-52892-1.C

raw
1 // PR c++/52892
2 // { dg-do compile { target c++11 } }
3
4 constexpr __SIZE_TYPE__ fibonacci(__SIZE_TYPE__ val) {
5 return (val <= 2) ? 1 : fibonacci(val - 1) + fibonacci(val - 2);
6 }
7
8 template <typename Function>
9 struct Defer {
10 constexpr Defer(const Function func_) : func(func_) { }
11
12 const Function func;
13
14 template <typename... Args>
15 constexpr auto operator () (const Args&... args) -> decltype(func(args...)) {
16 return func(args...);
17 }
18 };
19
20 template <typename Function>
21 constexpr Defer<Function> make_deferred(const Function f) {
22 return Defer<Function>(f);
23 }
24
25 int main() {
26 constexpr auto deferred = make_deferred(&fibonacci);
27 static_assert(deferred(25) == 75025, "Static fibonacci call failed"); // { dg-error "no match for call" "" { target c++14 } }
28 }