On Friday, 19 March 2021 at 07:14:46 UTC, Jack wrote:
give below template struct, how can I list the members x, y and z? I've tried something with OriginalType and TemplateOf but no luck... it seems if I do foo!"str1" the "str1" became "part of type"? give .stringof from typeof(__traits(getMember, foo, field)) I thought the type would be foo!string or something.

Template parameter cannot only be types but also values, including strings. If you instantiate a template with different values you get different types.

--
struct foo(T) { }
struct bar(string s) {}

alias a = foo!string; // type of a is foo!string
alias b = bar!"str1"; // type of b is bar!"str1"
alias c = bar!"str2"; // typo of c is bar!"str2"
static assert (!is(typeof(c) == typeof(b)));
--

Reply via email to