How templates work (bonus) - Full instantiation of Iota!(1,5)
Stefan Koch
uplink.coder at googlemail.com
Thu Jun 4 11:33:48 UTC 2020
As part of my series of templates
I have done a a full instantiation of Iota!(1,5).
(By hand!)
And here is the result:
Iota!(1,5)
{
{
alias Iota = Seq!(1, Iota!(1 + 1, 5));
}
Seq!(1, Iota!(1 + 1, 5))
{
alias Seq = (1, Iota!(1 + 1, 5));
Iota!(1 + 1, 5) => Iota!(2, 5)
{
alias Iota = Seq!(2, Iota!(2 +1, 5));
}
Seq!(2, Iota(2 + 1, 5))
{
alias seq = (2, Iota!(2 + 1, 5))
Iota!(2 + 1, 5) => Iota!(3, 5)
{
alias Iota = Seq!(3, Iota!(3 +1, 5));
}
Seq!(3, Iota!(3 + 1, 5))
{
alias Seq = (3, Iota!(3 + 1, 5));
Iota!(3 + 1, 5) => Iota!(4, 5)
{
alias Iota = Seq!(4, Iota!(4 +1, 5));
Seq!(4, Iota!(4 + 1, 5))
{
alias seq = (4, Iota!(4 + 1, 5));
Iota!(4 + 1, 5) => Iota!(5, 5)
{
{
alias Iota = Seq!();
{ Seq!() => () }.Seq => ()
}
}.Iota => Seq!()
}.Seq => (4, Seq!())
}.Iota => (3, Seq!(4, Seq!())
}.Seq => (3, Seq!(4, Seq())))
}.Seq => (2, (Seq!(3, Seq!(4, Seq!()))))
}.Seq => (1, Seq!(2, Seq!(3, Seq(4, Seq!())))))
}.Iota => (1, Seq!(2, Seq!3, Seq!4, Seq!()))))))
Because it has been done manually there are probably some bugs.
Can you find them all?
More information about the Digitalmars-d
mailing list