1 #include "TemplateMetaProgramming.h"
10 // See chapter 28 of "The C++ programming language".
12 namespace TemplateMetaProgramming
17 static const i64 val
= Fib
<I
- 1>::val
+ Fib
<I
- 2>::val
;
23 static const i64 val
= 0;
29 static const i64 val
= 1;
35 i64
fib_impl(integer_sequence
<i64
, I
...>, const i64 i
)
37 constexpr array
<i64
, sizeof...(I
)> a
= { Fib
<I
>::val
... };
43 // Generate all fibonacci sequence from 0 to 80.
44 return fib_impl(make_integer_sequence
<i64
, 81>(), i
);
48 void TemplateMetaProgramming::tests()
51 cout
<< "Compile time: fib(" << n
<< ") = " << Fib
<n
>::val
<< endl
;
54 cout
<< "Run time: fib(" << m
<< ") = " << fib(m
) << endl
;