> You wouldn't pass, because you didn't read the specs!
> "prints the numbers from 1 to 100." -- you printed 0-100! ;-)
This is specifically addressed in the "Exit Portability" section:
"1. It starts at 0 instead of 1. This is just to make the output more readable by having the number encoded in the template argument (T0, T1, T2, etc) map directly to its FizzBuzz representation. If you want a strict version of FizzBuzz, just change the template specialization to terminate on '1' and return a vector<int_<1> > instead."
That's not actually the precompiler. The "precompiler" in C++ is the pre-processor, which just does straightforward text substitution. Template metaprogramming uses (abuses) the compiler itself. Templates in C++ are Turing Complete: http://netvor.sk/~umage/docs/3rdparty/C++%20Templates%20are%...
oh, sorry for the terminology glitch. Know about turing completeness, have used it for optimizing execution speed of programs and making TAs go insane.
Um, nope, it is within the spec. The spec doesn't mention not printing other numbers. He met the req of printing 1-100 (he just also happened to print 0).
Comments
You wouldn't pass, because you didn't read the specs!
"prints the numbers from 1 to 100." -- you printed 0-100! ;-)
Just kidding, nice solution. Show's nicely how terrible and awesome the precompiler is.
> You wouldn't pass, because you didn't read the specs!
> "prints the numbers from 1 to 100." -- you printed 0-100! ;-)
This is specifically addressed in the "Exit Portability" section:
"1. It starts at 0 instead of 1. This is just to make the output more readable by having the number encoded in the template argument (T0, T1, T2, etc) map directly to its FizzBuzz representation. If you want a strict version of FizzBuzz, just change the template specialization to terminate on '1' and return a vector<int_<1> > instead."
That's not actually the precompiler. The "precompiler" in C++ is the pre-processor, which just does straightforward text substitution. Template metaprogramming uses (abuses) the compiler itself. Templates in C++ are Turing Complete: http://netvor.sk/~umage/docs/3rdparty/C++%20Templates%20are%...
oh, sorry for the terminology glitch. Know about turing completeness, have used it for optimizing execution speed of programs and making TAs go insane.
Um, nope, it is within the spec. The spec doesn't mention not printing other numbers. He met the req of printing 1-100 (he just also happened to print 0).
By this logic, the following would also be an acceptable solution:
Also gets 0 wrong. It should be a FizzBuzz.