Skip to content

Instantly share code, notes, and snippets.

@pbackus
Created March 29, 2022 15:19
Show Gist options
  • Save pbackus/afb4b8a3a1b915fc4556bccd20914eb7 to your computer and use it in GitHub Desktop.
Save pbackus/afb4b8a3a1b915fc4556bccd20914eb7 to your computer and use it in GitHub Desktop.
/// 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));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment