alias type reduction

Philippe Sigaud philippe.sigaud at gmail.com
Sat Dec 15 14:21:10 PST 2012


> If you don't mind, could you see if your solutions work on the following
> code:
>
> http://dpaste.dzfl.pl/64025e0a
>
>
What you're doing here is a bit different (AFAICT). _A is a template, not a
'real' class. So, it has no classinfo. The only real type here is the
template instantiation you call A.

Honestly, I have trouble reading your code, even though mine look much like
yours. I really do not get what you're trying to do. Maybe I'm too tired.


This is possibly because I want to design the code to work with a variable
> number of arguments(hence my asking for the number of arguments of a
> templated class in the other post).
>
> e.g., I want
>
> class A(..., bool _NestLevel = true) { }
>
> then
>
> A(...) a; to create an object. (note the _NestLevel is "hidden")
>
> If A has only one template argument, _NestLevel, then I want this to
> reduce to
>
> A a;
>
> Thanks.
>

You should try to use templated factory functions:

auto makeA(..., bool _NestLevel = true)
{
    return new A!(..., _NestLevel)();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20121215/ce36a370/attachment.html>


More information about the Digitalmars-d-learn mailing list