override toString() for a tuple?

Steve D via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 3 22:35:18 PDT 2014


Is it possible to override std tuple's toString format?

so that
         auto a = tuple("hello",1,2,3);
         writeln(a);

prints
         ("hello", 1, 2, 3)
and not
         Tuple!(string, int, int, int)("hello", 1, 2, 3)


I'm aware I could write a custom formatter function, but it would 
be nice not to
have to use such a function for every tuple printed by the 
program.
Overriding toString() one time in program (if possible) would 
give the ideal default behaviour. (I would duplicate the current 
typecons.d toString() and strip off the prefix)

thanks for any help


More information about the Digitalmars-d-learn mailing list