expand variadic template parameters
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 10 14:38:02 PDT 2015
On Tuesday, 10 March 2015 at 19:11:22 UTC, André wrote:
> Hi,
>
> in this minified example I try to expand the variadic parmaters
> of
> foo to bar:
>
> import std.typecons;
>
> void foo(T ...)(T args)
> {
> bar(args.expand);
> }
>
> void bar(int i, string s){}
>
> void main()
> {
> foo(1, "a");
> }
>
> I got the syntax error: no property 'expand' for type '(int,
> string)'
> I understand args is a TypeTuple and therefore expand is not
> working.
> Is there a simple way to get it working?
>
> Kind regards
> André
Just to be clear, TypeTuple is a library construct defined in
std.typetuple. It doesn't have a .expand member as far as I know.
You're probably thinking of tuple.expand.
The type of `T ...` is not TypeTuple, but an internal tuple type
used by the compiler. TypeTuple is just some syntactic sugar
allowing you to create one of these compiler tuples.
More information about the Digitalmars-d-learn
mailing list