computation at compile time i.e. compile time functions usingtemplates

C

Carter

Hi,

I am a bit new when it comes to C++ and I wasnt sure how to go about
doing this. How does one compute values at compile which can be
plugged into a static const value using a template. I remember seeing
in a book I no longer have some method for doing this. For example the
book gives a method for computing at compile time the value of
Fibonacci sequence where the value is generated by the compiler.
Unfortunately I seem to have misplaced the book.

Thanks in advance,

Carter.
 
C

Carter

See C++ Template Metaprogramming, by Abrahams and Gurtovoy.  Basically,
you just define a template to instantiate itself recursively, and
specialize for the base case.

Thanks both.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top