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
// Creates a compile-time sequence of function call expressions
// that each call `func` with the next variadic template argument
template Map(alias func, args...)
{
auto ref lazyItem() {return func(args[0]);}
static if (args .length == 1)
{
alias Map = lazyItem;
}
else
{
// recurse
alias Map = AliasSeq!(lazyItem, Map!(func, args[1 .. $]));
}
}
static void test(int a, int b)
{
writeln(a); // 4
writeln(b); // 16
}
static int a = 2;
static int b = 4;
test(Map!(i => i ^^ 2, a, b));
writeln(a); // 2
writeln(b); // 4
test(Map!((ref i) => i *= i, a, b));
writeln(a); // 4
writeln(b); // 16
static void testRef(ref int a, ref int b)
{
writeln(a++); // 16
writeln(b++); // 256
}
testRef(Map!(function ref(ref i) => i *= i, a, b));
writeln(a); // 17
writeln(b); // 257
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.