On Thursday, 15 June 2017 at 20:34:39 UTC, Adam D. Ruppe wrote:
On Thursday, 15 June 2017 at 19:15:55 UTC, Jonathan Marler
wrote:
I've found that the fullyQualifiedName template in std.traits
is a good tool for creating mixin code, however, it doesn't
always work.
Why is it useful? I suggest you are probably doing it wrong.
https://stackoverflow.com/questions/32615733/struct-composition-with-mixin-and-templates/32621854#32621854
always use local names in string mixins. Don't try to build
strings with other names, just use the one you already have in
scope.
This example is contrived to demonstrate the usage, obviously you
would never need to use fullyQualifiedName!T if you can just use
the type name directly.
The common use case is when you'd like to mixin a type when it is
passed to a template. For example, I recently made an addition
to the bitfields function that adds support for other bool-like
types like std.traits.Flag. The bitfields template takes the
type as an alias parameter and then mixin's in the name of the
type, however, there's no general way to mixin the type from an
alias. It uses T.stringof in some cases, and I had to do some
hacky template stuff to make std.traits.Flag work.
fullyQualifiedName also doesn't work because of the issues
explained here.