digitalmars.D.learn - AliasSeq + isExpression type specialization behavior
- Brian Schott (9/9) Nov 09 2015 Given the following code:
- Marc =?UTF-8?B?U2Now7x0eg==?= (8/17) Nov 10 2015 This fails, too:
- Brian Schott (2/9) Nov 10 2015 You're talking about Tuple. I'm talking about AliasSeq.
- Marc =?UTF-8?B?U2Now7x0eg==?= (6/17) Nov 10 2015 A Tuple is just a struct with an AliasSeq member. Or seen from a
- Alex Parrill (5/14) Nov 10 2015 `:` in `is` is for testing whether the left type is implicitly
Given the following code: ``` import std.meta; static assert(is(char : dchar)); static assert(is(AliasSeq!(int, char) : AliasSeq!(int, char))); static assert(is(AliasSeq!(int, char) : AliasSeq!(int, dchar))); ``` The third static assert fails. Should it, given that the first and second pass?
Nov 09 2015
On Monday, 9 November 2015 at 22:41:50 UTC, Brian Schott wrote:Given the following code: ``` import std.meta; static assert(is(char : dchar)); static assert(is(AliasSeq!(int, char) : AliasSeq!(int, char))); static assert(is(AliasSeq!(int, char) : AliasSeq!(int, dchar))); ``` The third static assert fails. Should it, given that the first and second pass?This fails, too: static assert(is(AliasSeq!(char) : AliasSeq!(dchar))); Which makes sense IMO, because it can be thought of as an unnamed struct, cp. the following: struct A { char c; } struct B { dchar c; } static assert(is(A : B)); // fails, as expected
Nov 10 2015
On Tuesday, 10 November 2015 at 10:28:45 UTC, Marc Schütz wrote:This fails, too: static assert(is(AliasSeq!(char) : AliasSeq!(dchar))); Which makes sense IMO, because it can be thought of as an unnamed struct, cp. the following: struct A { char c; } struct B { dchar c; } static assert(is(A : B)); // fails, as expectedYou're talking about Tuple. I'm talking about AliasSeq.
Nov 10 2015
On Tuesday, 10 November 2015 at 13:47:23 UTC, Brian Schott wrote:On Tuesday, 10 November 2015 at 10:28:45 UTC, Marc Schütz wrote:A Tuple is just a struct with an AliasSeq member. Or seen from a different POV, an AliasSeq can be interpreted as the "innards" of the struct. IMO it therefore makes sense to expect an AliasSeq to behave analogously to a struct. The only exception to that is that AliasSeq auto-expands, of course.This fails, too: static assert(is(AliasSeq!(char) : AliasSeq!(dchar))); Which makes sense IMO, because it can be thought of as an unnamed struct, cp. the following: struct A { char c; } struct B { dchar c; } static assert(is(A : B)); // fails, as expectedYou're talking about Tuple. I'm talking about AliasSeq.
Nov 10 2015
On Monday, 9 November 2015 at 22:41:50 UTC, Brian Schott wrote:Given the following code: ``` import std.meta; static assert(is(char : dchar)); static assert(is(AliasSeq!(int, char) : AliasSeq!(int, char))); static assert(is(AliasSeq!(int, char) : AliasSeq!(int, dchar))); ``` The third static assert fails. Should it, given that the first and second pass?`:` in `is` is for testing whether the left type is implicitly convertible to the right type. `char` is implicitly convertible to `dchar` by promoting it. But `AliasSeq`s are collections; they're only implicitly convertible to themselves.
Nov 10 2015