| Thread overview | ||||||||
|---|---|---|---|---|---|---|---|---|
|
May 20, 2009 Why is !() need with default template arguments | ||||
|---|---|---|---|---|
| ||||
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 Re: Why is !() need with default template arguments | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | 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 Re: Why is !() need with default template arguments | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jeremie Pelletier | 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 Re: Why is !() need with default template arguments | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Lars T. Kyllingstad |
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 Re: Why is !() need with default template arguments | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jeremie Pelletier | 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 Re: Why is !() need with default template arguments | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Tim Matthews | 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.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply