How auto convert Variant to required function arguments?
Ferhat Kurtulmuş
aferust at gmail.com
Fri Oct 9 16:10:59 UTC 2020
On Friday, 9 October 2020 at 16:10:03 UTC, Ferhat Kurtulmuş wrote:
> On Friday, 9 October 2020 at 15:49:31 UTC, Ferhat Kurtulmuş
> wrote:
>> On Friday, 9 October 2020 at 00:19:20 UTC, Marcone wrote:
>>> How auto convert Variant to required function arguments?
>>
>>
>> import std.variant;
>> import std.stdio;
>>
>> Variant a;
>>
>> int mul2(Variant b){
>> int c = *b.peek!(int);
>> return 2*c;
>> }
>>
>> int mul3(int b){
>> return 3*b;
>> }
>>
>> void main()
>> {
>> a = 5;
>> writeln(mul2(a));
>>
>> Variant b = 3;
>> writeln(mul3(*b.peek!int));
>> }
> Uh, probably this is not what you want. I found this thread:
> https://forum.dlang.org/thread/ebylgcrslkelgrvntjws@forum.dlang.org
>
> You man need to use Algebraic.
may*
More information about the Digitalmars-d-learn
mailing list