Re: Traits of variadic templates

2021-02-09 Thread Jeff via Digitalmars-d-learn
On Tuesday, 9 February 2021 at 16:25:46 UTC, Paul Backus wrote: On Tuesday, 9 February 2021 at 16:22:16 UTC, Jeff wrote: But, those don't work because T is a Tuple of the types. Is there some trait combination I can use to do this? Something like (obviously made up)... all(TemplateArgsOf!T, t

Re: Traits of variadic templates

2021-02-09 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 9 February 2021 at 16:22:16 UTC, Jeff wrote: But, those don't work because T is a Tuple of the types. Is there some trait combination I can use to do this? Something like (obviously made up)... all(TemplateArgsOf!T, t => isIntegral!t || isSomeString!t) Thanks! import std.meta: a

Traits of variadic templates

2021-02-09 Thread Jeff via Digitalmars-d-learn
Let's say I have... void foo(T...)(T xs) { foreach(x; xs) { if (typeid(x) == typeid(int)) writeln("int: ", x); else writeln("str: ", x); } } From the body, it's obvious I really only want int or string to be passed in to foo. Ideally, this che