creating a variadic interface

Artur Skawina art.08.09 at gmail.com
Mon Jul 8 06:42:19 PDT 2013


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.

artur 


More information about the Digitalmars-d-learn mailing list