store template value

maarten van damme via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 1 11:24:21 PDT 2015


But it's std.parallelism's task...
And how can I use get!T if I don't know the type of the task?

2015-08-01 19:02 GMT+02:00 Adam D. Ruppe via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com>:

> On Saturday, 1 August 2015 at 16:41:54 UTC, maarten van damme wrote:
>
>> I was afraid I would have to do that. Templatizing the class on the value
>> doesn't work as I later on want to create a hashmap of these classes. When
>> I assign a task to a variant, how do I call .yieldForce later on?
>>
>
>
> You can get a type from a Variant with the get!T method then call it.
>
> But actually, maybe Task should just be an interface with the yieldForce
> method then you create classes that implement it and pass them to the
> constructor. Then there's no need for templates or casting at all.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150801/81cdec36/attachment.html>


More information about the Digitalmars-d-learn mailing list