Are named variadic arguments possible?

downs default_357-line at yahoo.de
Tue Jan 5 03:43:43 PST 2010


Alex wrote:
> Is it possible, using templates, tuples, or some other mechanism, to implement named variadic arguments in D?
> 
> For example, I'd like to be able to do something like...
> foo( 2, &bar, age : 10, status : "down");
> 
> and so forth.

Yes, with a small hack.

typedef int age_type;

age_type age(int i) { return cast(age_type) i; }

void foo(T...)(int i, Bar*, T t) {
  // Test T for age_type here.
}


More information about the Digitalmars-d-learn mailing list