[Issue 11711] New: Add __traits(getAliasThis)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 7 23:15:49 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11711
Summary: Add __traits(getAliasThis)
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2013-12-07 23:15:46 PST ---
Currently, std.traits.XXXTypeOf is implemented in tricky. To fix the
complexity, I'd like to propose a new __trait.
alias Seq(T...) = T;
alias TypeTuple = Seq;
import std.typetuple;
struct S1
{
string var;
alias var this;
}
static assert(__traits(getAliasThis, S1) == TypeTuple!("var"));
// __traits(getAliasThis) returns a tuple of alias this member names
static assert(is(typeof(__traits(getMember, S1.init, __traits(getAliasThis,
S1)[0])) == string));
// Extract the alias this type by using the combination with
__traits(getMember).
struct S2
{
TypeTuple!(int, string) var;
alias var this;
}
static assert(__traits(getAliasThis, S2) == TypeTuple!("var"));
static assert(is(typeof(__traits(getMember, S2.init, __traits(getAliasThis,
S2)[0])) == TypeTuple!(int, string)));
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list