Template argument deduction and default args

anonymous via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 24 04:42:23 PDT 2014


On Thursday, 24 July 2014 at 06:17:26 UTC, Manu via Digitalmars-d
wrote:
> On 24 July 2014 16:02, anonymous via Digitalmars-d <
> digitalmars-d at puremagic.com> wrote:
>
>> On Thursday, 24 July 2014 at 04:53:41 UTC, Manu via 
>> Digitalmars-d
>> wrote:
[...]
>>>  This causes problems in meta code, where you want to create 
>>> an instance of
>>> some T, and T may be a normal type with no template args, in 
>>> which case
>>> !()
>>> is invalid, but a template type with default args should also 
>>> be
>>> acceptable, but it doesn't work because the meta code doesn't 
>>> specify !().
>>>
>>
>> Add !() at the instantiation site.
>
>
> Then the code is broken for any type that isn't a template... 
> it's a
> mutually exclusive situation.

I mean, don't accept both types and templates. Demand types in
the meta code, and do the instantiation of S when instantiating
the meta code: metaCode!(S!()).

I understand that it's a bit ugly, but I don't see the bigger
issue here. Do you have an example where there's more to it than
just having to add !() somewhere?

I do see the problem with the other case, S(T) {this(T) {...}},
though. You can't just do metaCode!(S!()) there.


More information about the Digitalmars-d mailing list