Simple overloading without complications

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 12 11:53:23 PDT 2016


On Tuesday, 12 July 2016 at 18:52:08 UTC, Meta wrote:
> On Tuesday, 12 July 2016 at 04:23:07 UTC, Adam Sansier wrote:
>> Now, I could simply make Do a template method but then this 
>> prevents it being a virtual function.
>>
>> void Do(T)(T name) if (is(T == string) || is(T == int))
>> {
>>     Init_Data();
>>
>>     static if (is(T == string))
>>     {
>>         ...Get index from name
>>     }
>>
>>     ....
>> }
>
> You could always use std.variant.algebraic which implements 
> runtime polymorphism:
>
> import std.algebraic;

Should be `import std.variant`.



More information about the Digitalmars-d-learn mailing list