digitalmars.D.learn - Get the type of 'alias this ='
- Vladimirs Nordholm (23/23) Apr 04 2018 Hello people from D-land.
- Vladimirs Nordholm (3/9) Apr 04 2018 Oops, typo in the alias. Should be `alias e this`
- Simen =?UTF-8?B?S2rDpnLDpXM=?= (5/6) Apr 04 2018 if (is(T : Enum))
- Vladimirs Nordholm (2/8) Apr 04 2018 Ah! Thanks a lot!
Hello people from D-land. Short question: Can get the type of a struct that has `alias this = <type>` ? See this example, where a struct is aliased to an enum: enum Enum { one, two, three, fourtytwo } private template Mix() { this(Enum ee) { e = ee; } Enum e; alias this = e; } struct A { mixin Mix } struct B { mixin Mix } T foo(T) (T f) if (is(T == A) || is(T == B) || is(T == Enum)) // |------------------------------------------| // ^ I want to change this into something more nice looking { // ... } I want to check the type in a more 'cleaner' way. Best regards, Vladimirs Nordholm
Apr 04 2018
On Wednesday, 4 April 2018 at 15:49:31 UTC, Vladimirs Nordholm wrote:private template Mix() { this(Enum ee) { e = ee; } Enum e; alias this = e; }Oops, typo in the alias. Should be `alias e this`
Apr 04 2018
On Wednesday, 4 April 2018 at 15:49:31 UTC, Vladimirs Nordholm wrote:if (is(T == A) || is(T == B) || is(T == Enum))if (is(T : Enum)) -- Simen
Apr 04 2018
On Wednesday, 4 April 2018 at 15:57:19 UTC, Simen Kjærås wrote:On Wednesday, 4 April 2018 at 15:49:31 UTC, Vladimirs Nordholm wrote:Ah! Thanks a lot!if (is(T == A) || is(T == B) || is(T == Enum))if (is(T : Enum)) -- Simen
Apr 04 2018