repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Rebase.
[official-gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
cpp0x
/
lambda
/
lambda-recursive.C
blob
cbaeb16201f6a308c6c37857fc555884b37f042e
1
// { dg-do run { target c++11 } }
2
3
//#include <iostream>
4
#include <functional>
5
#include <cassert>
6
7
int main() {
8
9
std::function<int(int)> fib = [&fib] (int n) -> int {
10
//std::cerr << "fib(" << n << ")\n";
11
if (n <= 2) return 1;
12
else return fib(n-1) + fib(n-2);
13
};
14
15
assert(fib(5) == 5);
16
assert(fib(10) == 55);
17
18
return 0;
19
}
20