View source code
Display the source code in std/meta.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Alias std.meta.AliasSeq
Creates a sequence of zero or more aliases. This is most commonly used as template parameters or arguments.
alias AliasSeq(TList...)
= TList;
In previous versions of Phobos, this was known as TypeTuple
.
Example
import std .meta;
alias TL = AliasSeq!(int, double);
int foo(TL td) // same as int foo(int, double);
{
return td[0] + cast(int) td[1];
}
Example
alias TL = AliasSeq!(int, double);
alias Types = AliasSeq!(TL, char);
static assert(is(Types == AliasSeq!(int, double, char)));
Example
Returns an AliasSeq
expression of Func
being
applied to every variadic template argument.
auto ref ArgCall(alias Func, alias arg)()
{
return Func(arg);
}
template Map(alias Func, args...)
{
static if (args .length > 1)
{
alias Map = AliasSeq!(ArgCall!(Func, args[0]), Map!(Func, args[1 .. $]));
}
else
{
alias Map = ArgCall!(Func, args[0]);
}
}
static int square(int arg)
{
return arg * arg;
}
static int refSquare(ref int arg)
{
arg *= arg;
return arg;
}
static ref int refRetSquare(ref int arg)
{
arg *= arg;
return arg;
}
static void test(int a, int b)
{
writeln(a); // 4
writeln(b); // 16
}
static void testRef(ref int a, ref int b)
{
writeln(a++); // 16
writeln(b++); // 256
}
static int a = 2;
static int b = 4;
test(Map!(square, a, b));
test(Map!(refSquare, a, b));
writeln(a); // 4
writeln(b); // 16
testRef(Map!(refRetSquare, a, b));
writeln(a); // 17
writeln(b); // 257
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.