creating a variadic interface

Artur Skawina art.08.09 at gmail.com
Mon Jul 8 07:25:02 PDT 2013


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


More information about the Digitalmars-d-learn mailing list