On Wednesday, 17 August 2016 at 18:38:48 UTC, Engine Machine
wrote:
On Wednesday, 17 August 2016 at 08:37:32 UTC, Lodovico Giaretta
wrote:
On Tuesday, 16 August 2016 at 23:18:28 UTC, Adam D. Ruppe
wrote:
[...]
You mean something like:
struct MySequence(Args...)
{
enum length = Args.length;
alias args = Args;
}
alias x = MySequence!(a, b, MySequence!(c, d));
static assert(x.length == 3)
static assert(x.args[2].length == 2);
Thanks, basically works.
How can I test, though, if a argument uses a MySequence? I
can't do if (Args[0] == MySequence) because MySequence is
templated. While I could test for a length, that doesn't work
because some types have a length. I could add another enum to
MySequence, but again, not safe.
I could do some string tests, but that doesn't work.
in your exmaple,
if (x.args[2] == MySequence) ??
I simply need to differentiate between a parameter/arg being a
MySequence and not.
I guess I'll go with something like
static if ((a.Args[2]).stringof[0..11] == "MySequence!")
Doesn't feel entirely safe but probably will work without issue.
Maybe there is a better way?