Thread overview
Why is !() need with default template arguments
May 20, 2009
Jacob Carlborg
May 20, 2009
Jeremie Pelletier
May 20, 2009
Daniel Keep
May 20, 2009
Tim Matthews
May 20, 2009
Jeremie Pelletier
May 20, 2009
If I have a class like this:

class Class (T = int) {}

Then why can't I use it like this:

auto c = new C;

I have to do this:

auto c = new C!();
May 20, 2009
Jacob Carlborg Wrote:

> If I have a class like this:
> 
> class Class (T = int) {}
> 
> Then why can't I use it like this:
> 
> auto c = new C;
> 
> I have to do this:
> 
> auto c = new C!();

I think it is so the parser knows how to make the difference between the template symbol and an instance symbol.

May 20, 2009
Jeremie Pelletier wrote:
> Jacob Carlborg Wrote:
> 
>> If I have a class like this:
>>
>> class Class (T = int) {}
>>
>> Then why can't I use it like this:
>>
>> auto c = new C;
>>
>> I have to do this:
>>
>> auto c = new C!();
> 
> I think it is so the parser knows how to make the difference between the template symbol and an instance symbol.
> 

Can you do anything with a template except instantiate it?

-Lars
May 20, 2009

Lars T. Kyllingstad wrote:
> Can you do anything with a template except instantiate it?
> 
> -Lars

Pass it to another template as an alias argument.

  -- Daniel
May 20, 2009
On Wed, 20 May 2009 15:01:44 +1200, Jeremie Pelletier <jeremiep@gmail.com> wrote:


> I think it is so the parser knows how to make the difference between the template symbol and an instance symbol.
>


Can you explain a bit more on this? function templates dont require this by the way and I didn't think a template could ever be 'newed'
May 20, 2009
Tim Matthews Wrote:

> On Wed, 20 May 2009 15:01:44 +1200, Jeremie Pelletier <jeremiep@gmail.com> wrote:
> 
> 
> > I think it is so the parser knows how to make the difference between the template symbol and an instance symbol.
> >
> 
> 
> Can you explain a bit more on this? function templates dont require this by the way and I didn't think a template could ever be 'newed'

Oh yeah you are right, it has already been filed as a bug.