On Monday, 25 June 2018 at 00:35:40 UTC, Jonathan M Davis wrote:
On Sunday, June 24, 2018 23:53:09 Timoses via Digitalmars-d
wrote:
On Sunday, 24 June 2018 at 23:34:49 UTC, Per Nordlöw wrote:
> Provided that
>
> __traits(allMembers, E)
>
> is a cheap operation as it's called once for every
> enumerator. I could get it out of the loop; if I do as
>
> @property string toString() @safe pure nothrow @nogc
> {
>
> final switch (_enum)
> {
>
> enum members = __traits(allMembers, E);
enum members = [_traits(allMembers, E)];
seems to work
Or if you want it to stay an AliasSeq, then just use Alias or
AliasSeq on it. e.g.
alias members = AliasSeq!(__traits(allMembers, E));
Given that the result of __traits in this case is an AliasSeq,
I have no idea why the gramar doesn't allow you to just use the
result of __traits directly as an AliasSeq with something like
alias members = __traits(allMembers, E);
but it doesn't. So, you have to wrap it, dumb as that may be.
There's a bug report about it in bugzilla somewhere.
https://issues.dlang.org/show_bug.cgi?id=16390
I guess? First search result : D