C++ Template Metaprogramming
Solutions to the exercises throughout the book
Loading...
Searching...
No Matches
exercise-5-9.hpp
Go to the documentation of this file.
1// ===-- chapter-5/exercise-5-9.hpp ----------------------- -*- C++ -*- --=== //
9#ifndef EXERCISE_5_9
10#define EXERCISE_5_9
11
12#include "exercise-5-8.hpp"
13
14
33static size_t const sMaxFibForInt32 = 45;
34
35namespace boost {
36namespace mpl {
37
40
42template <>
43struct next< exercise_5_8::fibonacci_series_iterator<1134903170, 701408733> >
44{
45 // Compilation error...
46};
47
49template <size_t N, size_t LastN>
50struct prior< exercise_5_8::fibonacci_series_iterator<N, LastN> >
51{
53};
54
56template <> struct prior< exercise_5_8::fibonacci_series_iterator<1, 1> >
57{
59};
60
62template <> struct prior< exercise_5_8::fibonacci_series_iterator<0, 1> >
63{
64 // Compilation error
65};
66
68
69} // namespace mpl
70} // namespace boost
71
72#endif // EXERCISE_5_9
Solution to Exercise 5-8.
static size_t const sMaxFibForInt32
For a 32-bit signed integer, the max Fibonacci sequence seems to be this.
Exists to inject functionality into the Boost MPL namespace.
Exists to inject functionality into the Boost namespace.
Encapsulate solution for Exercise 5-8.
exercise_5_8::fibonacci_series_iterator< 0, 1 > type
exercise_5_8::fibonacci_series_iterator< LastN, N-LastN > type
Iterator for moving through Fibonacci series sequence.