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;
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
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
On Friday, 2 February 2024 at 20:28:50 UTC, Carl Sturtivant wrote:
On Friday, 2 February 2024 at 19:22:22 UTC, Steven
Schveighoffer wrote:
```d
// shim
auto foo(Args...)(Args args) if (!allSatisfy!(isVariant, Args))
{
mixin("return foo(", argsAsVariants(args.length), ");");
}
```
Thanks
On Friday, 2 February 2024 at 19:22:22 UTC, Steven Schveighoffer
wrote:
```d
void foo(Variant x, Variant y) { ... }
import std.meta : allSatisfy;
enum isVariant(T) = is(T == Variant);
// this is going to suck at CTFE but...
string argsAsVariants(size_t count)
{
import std.format;
import
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?
You'd have to implement the function that accepts the parameters
and wraps in a Variant.
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 actually pass it a `Variant` with
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?
Just tell the compiler clearly what you want.
```d
import std;
void f(Variant x) {
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?