Re: Scripting with Variant from std.variant: parameter passing

2024-02-03 Thread Danilo via Digitalmars-d-learn
On Friday, 2 February 2024 at 11:31:09 UTC, Anonymouse wrote: On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote: It seems I cannot pass e.g. an int argument to a Variant function parameter. What's the simplest way to work around this restriction? The easiest thing would be to

Re: Scripting with Variant from std.variant: parameter passing

2024-02-03 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 3 February 2024 at 08:04:40 UTC, Danilo wrote: To be honest, this doesn't make sense. `if (!is(T : Variant))` returns true for inputs like 42, "hello", 3.14f, but the input is not a Variant but a random type. Yes, it's nice that it works in this case. It's just not logical, it

Re: template/mixin magic for to! auto inferring type from variable

2024-02-03 Thread kdevel via Digitalmars-d-learn
On Saturday, 3 February 2024 at 02:20:13 UTC, Paul Backus wrote: On Friday, 2 February 2024 at 23:25:37 UTC, Chris Katko wrote: The auto solution won't work for a struct however which I'm using: ```D struct procTable{ //contains all the fields inside a file I'm parsing uint time; int p

Re: Scripting with Variant from std.variant: parameter passing

2024-02-03 Thread Carl Sturtivant via Digitalmars-d-learn
On Friday, 2 February 2024 at 20:58:12 UTC, Paul Backus wrote: Another variation on the same theme: ```d /// map over a variadic argument list template mapArgs(alias fun) { auto mapArgs(Args...)(auto ref Args args) { import std.typecons: tuple; impo