creating a variadic interface

John Colvin john.loughran.colvin at gmail.com
Mon Jul 8 07:12:32 PDT 2013


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.
>
> artur

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.


More information about the Digitalmars-d-learn mailing list