Here\'s some code (full program follows later in the question):
template
T fizzbuzz(T n) {
T count(0);
#if CONST
const T d
The difference in speed is caused by the compiler not knowing if "div" will change value. When it is non-const, it is treating it like a variable being passed in. It could be anything, and so the compiler will use an instruction that divides two variables - idivl. When you say that it's const, the compiler is free to treat it exactly as if you'd typed:
if (i % 3 == 0)
I'm kind of surprised that it didn't use bitwise AND(&).
The WrappedInt isn't being optimized because, well, its not an int. Its a class.
Something that you could do is incorporate fizzbuzz into WrappedInt.