View source code
Display the source code in std/meta.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aBugzilla 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 usinglocal clone.
Alias std.meta.Repeat
Creates an AliasSeq
which repeats items
exactly n
times.
Example
alias ImInt0 = Repeat!(0, int);
static assert(is(ImInt0 == AliasSeq!()));
alias ImInt1 = Repeat!(1, immutable(int));
static assert(is(ImInt1 == AliasSeq!(immutable(int))));
alias Real3 = Repeat!(3, real);
static assert(is(Real3 == AliasSeq!(real, real, real)));
alias Real12 = Repeat!(4, Real3);
static assert(is(Real12 == AliasSeq!(real, real, real, real, real, real,
real, real, real, real, real, real)));
alias Composite = AliasSeq!(uint, int);
alias Composite2 = Repeat!(2, Composite);
static assert(is(Composite2 == AliasSeq!(uint, int, uint, int)));
alias ImInt10 = Repeat!(10, int);
static assert(is(ImInt10 == AliasSeq!(int, int, int, int, int, int, int, int, int, int)));
alias Big = Repeat!(1_000_000, int);
Example
auto staticArray(T, size_t n)(Repeat!(n, T) elems)
{
T[n] a = [elems];
return a;
}
auto a = staticArray!(long, 3)(3, 1, 4);
assert(is(typeof(a) == long[3]));
writeln(a); // [3, 1, 4]
Authors
License
Copyright © 1999-2025 by the D Language Foundation | Page generated by ddox.