Alright thanks! That is good news.
Alright thanks! That is good news.
The only compiles that are too retarded to optimize out "10 / 5" are unlikely to be able to handle these advanced template constructs, I think. So I think it would be really bad to use a messy construct like this.
In fact, I find it more likely a compiler is unable to optimize something like divide<10, 5>*3 than it 10 / 5 * 3...
No one would write that, he's showing off
The point was that it will be optimized even in Debug mode. In Release, I'm sure the compiler will optimize it.
And any compiler that is able to instantiate a template like this will have no problems optimizing divide<10, 5> * 3.
And some might write like this, if not for exactly division, but for other things such as binary -> decimal or whatever.
How do you know the compiler doesn't already evaluate constant expressions in debug build? E.g with gcc:
Code:int a = 14 / 2;Code:.stabn 68,0,5,LM3-_main LM3: movl $7, -4(%ebp)
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Well, as I said, with optimizations on (ie Release build), then it 99% likely will.
But in Debug mode (ie no optimizations), it most likely will not (VC++ will not).
And if they aren't constant expressions, then neither will work very well (unless we talk about SSE & Co).
Then why optimize arithmetic in debug builds at all?