consider the following template class:

template<bool doit>
class myclass
{
void MyMethod()
{
if(doit)
{
...
}
}
};

myclass<false> m;
m.MyMethod();

Q: Would the optimizer (VC7.0) exclude this function call
since 'doit' is known at compile time and can be resolved?

Regards, DI

Re: templates & optimization by Alexander

Alexander
Fri Aug 15 10:41:57 CDT 2003

Dead code elimination is known since 16-bit compilers. And the functions
defined inside the class definition are considered inline.

"DanI" <ingallas@bresnan.net> wrote in message
news:062201c362b4$3f1964d0$a301280a@phx.gbl...
> consider the following template class:
>
> template<bool doit>
> class myclass
> {
> void MyMethod()
> {
> if(doit)
> {
> ...
> }
> }
> };
>
> myclass<false> m;
> m.MyMethod();
>
> Q: Would the optimizer (VC7.0) exclude this function call
> since 'doit' is known at compile time and can be resolved?
>
> Regards, DI