Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualL. Spiro

Posted 14 January 2013 - 12:17 AM

The only useful/practical use I have ever had for this type of template metaprogramming was to calculate the size of a quad-tree at compile-time depending on how many levels I want there to be.

For 8 levels you would have 21,845 cells and it is best to keep them in 1 contiguous memory block made via 1 allocation. Not only does this improve cache performance but it allows for instant insertion into any cell in the tree. I plan to explain this method for creating a quad-tree in an upcoming tutorial as it is extremely efficient.

I don’t need to post code for such a simple thing but this is an example of a real-world situation where these tricks that allow compile-time Fibonacci sequences can be usefully employed.


L. Spiro

#1L. Spiro

Posted 14 January 2013 - 12:16 AM

The only useful/practical use I have even had for this type of template metaprogramming was to calculate the size of a quad-tree at compile-time depending on how many levels I want there to be.

For 8 levels you would have 21,845 cells and it is best to keep them in 1 contiguous memory block made via 1 allocation. Not only does this improve cache performance but it allows for instant insertion into any cell in the tree. I plan to explain this method for creating a quad-tree in an upcoming tutorial as it is extremely efficient.

I don’t need to post code for such a simple thing but this is an example of a real-world situation where these tricks that allow compile-time Fibonacci sequences can be usefully employed.


L. Spiro

PARTNERS