mixed-in ctor not on par with explicit one?

Daniel N via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 13 05:53:01 PST 2016


On Wednesday, 13 January 2016 at 12:39:36 UTC, Jacob Carlborg 
wrote:
> On 2016-01-13 10:48, Shriramana Sharma wrote:
>
>> This is not what alias <> this is supposed to do, right?
>
> No.
>
>> So how am I supposed to get the mixed in ctors work?
>
> Looks like a limitation in the language.

This works:

mixin template myCtors()
{
     this(int i) {}
     this(char c) {}
}
struct Test
{
     this(string s) {}

     mixin myCtors  mixed;
     alias __ctor = mixed.__ctor;
}
void main()
{
     auto a = Test("hello");
     auto b = Test(1);
     auto c = Test('c');
}



More information about the Digitalmars-d-learn mailing list