digitalmars.D.learn - How auto convert Variant to required function arguments?
- Marcone (1/1) Oct 08 2020 How auto convert Variant to required function arguments?
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (18/19) Oct 09 2020 import std.variant;
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (4/23) Oct 09 2020 Uh, probably this is not what you want. I found this thread:
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (2/33) Oct 09 2020 may*
How auto convert Variant to required function arguments?
Oct 08 2020
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)); }
Oct 09 2020
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: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.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)); }
Oct 09 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:may*On Friday, 9 October 2020 at 00:19:20 UTC, Marcone wrote: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.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)); }
Oct 09 2020