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;
                import core.lifetime: forward;
                import std.meta: Map = staticMap;

                auto ref mapArg(alias arg)()
                {
                        return fun(forward!arg);
                }

                return tuple(Map!(mapArg, args));
        }
}

import std.variant: Variant;
import std.meta: allSatisfy;

enum isVariant(T) = is(T == Variant);

auto foo(Args...)(Args args)
    if (!allSatisfy!(isVariant, Args))
{
    return .foo(mapArgs!Variant(args).expand);
}
```

Thanks, will study the library machinery you used here.

Reply via email to