On Monday, 8 July 2013 at 14:25:17 UTC, Artur Skawina wrote:
On 07/08/13 16:12, John Colvin wrote:
On Monday, 8 July 2013 at 13:42:36 UTC, Artur Skawina wrote:
On 07/08/13 15:12, John Colvin wrote:
On Monday, 8 July 2013 at 13:01:32 UTC, Artur Skawina wrote:
It won't work if one of the types isn't already available
inside the
template - the .stringof will give you the name, but the
mixin
will fail;
When would the type not be available?
auto as() { struct An {} return An(); }
template A(T) {}
A!(typeof(as()))
T.stringof inside 'A' will return a name, but there's no way
to map
it back to a type.
The 'A' template can be instantiated from a different module
- the type
won't be available in A if A doesn't import that other module.
The type may be private, then even an import in A (or any
parent scope)
won't help.
Ah ok, I see.
In those cases you're not going to be able to declare a
function that explicitly uses that type anyway, whether
handwritten or generated as above.
struct A(T) { T f(T a) { return a.blah; } }
artur
Right.... So the problem is that there's no mapping available
between the type name and the type, not that the type itself is
unavailable for use. Don't know why I'm being so slow with this
today...must be the heat!