
On 6/8/06 10:06 AM, "Dale McCoy"
On 6/2/06, Gottlob Frege
wrote: Is there really no way to templatize
a) a zero argument constructor
It's been a long time since I've used default values for templates in my code, but I think this should work:
class foo{ template<typename __dummy=int>foo(); };
This can't work. There is no way to explicitly specify the template arguments for a constructor template. All types/values for the template arguments must be implied from the constructor's functional arguments. This makes a default constructor template pointless, since there wouldn't be any way to prevent ambiguity.
b) a destructor
The above template<typename __dummy=int> trick may work here too.
There is always _exactly_ one destructor for a class (which can be implicit by the compiler), so the very concept of making a destructor template is meaningless. Remember that the destructor has to work no matter which constructor was used, which is why base and member construction order is fixed by the class layout and not the call order within a constructor.
I'm trying to delay the compile of the functions until everything is known.
I'm not following. If they're in a template class, they can't be compiled until everything is known, regardless. If they aren't in a template class, then everything is always known.
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com