Function template arg promotion

Artur Skawina art.08.09 at gmail.com
Fri Feb 3 07:10:58 PST 2012


------------------------------------------------------------------------
void set_from_4ub_f(ubyte red, ubyte green, ubyte blue, ubyte alpha) { }
void set_from_4ub()(ubyte red, ubyte green, ubyte blue, ubyte alpha) { }

void f() {
   set_from_4ub_f(0x00, 0x00, 0x00, 0xff); // Works.
   set_from_4ub(0x00, 0x00, 0x00, 0xff);   // Fails.
}
------------------------------------------------------------------------

results in:

templargpromo.d:6: Error: template templargpromo.set_from_4ub() does not match any function template declaration
templargpromo.d:6: Error: template templargpromo.set_from_4ub() cannot deduce template function from argument types !()(int,int,int,int)


Any way to make the template version work, without requiring changes for users?
And without having to cast the args back to ubyte before using them?

artur


More information about the Digitalmars-d mailing list