URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [lambda/] [lambda-recursive.C] - Rev 301
Go to most recent revision | Compare with Previous | Blame | View Log
// { dg-do "run" }
// { dg-options "-std=c++0x" }
//#include <iostream>
#include <functional>
#include <cassert>
int main() {
std::function<int(int)> fib = [&fib] (int n) -> int {
//std::cerr << "fib(" << n << ")\n";
if (n <= 2) return 1;
else return fib(n-1) + fib(n-2);
};
assert(fib(5) == 5);
assert(fib(10) == 55);
return 0;
}
Go to most recent revision | Compare with Previous | Blame | View Log