Boost logo

Boost Users :

From: Daryle Walker (darylew_at_[hidden])
Date: 2006-06-16 04:00:01


On 6/8/06 10:06 AM, "Dale McCoy" <dalestan_at_[hidden]> wrote:

> On 6/2/06, Gottlob Frege <gottlobfrege_at_[hidden]> 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

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net