digitalmars.D - Function template arg promotion
- Artur Skawina (14/14) Feb 03 2012 ------------------------------------------------------------------------
- Daniel Murphy (4/4) Feb 03 2012 void set_from_4ub(dummy = int)(ubyte red, ubyte green, ubyte blue, ubyte...
- Artur Skawina (5/10) Feb 03 2012 That doesn't change anything; the issue is: the "int" literals wont
- Daniel Murphy (4/14) Feb 03 2012 Ah ok, I just guessed. It sounds like you've hit
- Timon Gehr (3/17) Feb 03 2012 It should already work. It is a bug, probably related to
------------------------------------------------------------------------ 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
Feb 03 2012
void set_from_4ub(dummy = int)(ubyte red, ubyte green, ubyte blue, ubyte alpha) { } ?? (not tested)
Feb 03 2012
On 02/03/12 17:39, Daniel Murphy wrote:void set_from_4ub(dummy = int)(ubyte red, ubyte green, ubyte blue, ubyte alpha) { } ?? (not tested)That doesn't change anything; the issue is: the "int" literals wont implicitly convert to ubyte, even when there is no better match and an assignment would succeed. artur
Feb 03 2012
Ah ok, I just guessed. It sounds like you've hit http://d.puremagic.com/issues/show_bug.cgi?id=4953 "Artur Skawina" <art.08.09 gmail.com> wrote in message news:mailman.343.1328308873.25230.digitalmars-d puremagic.com...On 02/03/12 17:39, Daniel Murphy wrote:void set_from_4ub(dummy = int)(ubyte red, ubyte green, ubyte blue, ubyte alpha) { } ?? (not tested)That doesn't change anything; the issue is: the "int" literals wont implicitly convert to ubyte, even when there is no better match and an assignment would succeed. artur
Feb 03 2012
On 02/03/2012 04:10 PM, Artur Skawina wrote:------------------------------------------------------------------------ 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? arturIt should already work. It is a bug, probably related to http://d.puremagic.com/issues/show_bug.cgi?id=7366
Feb 03 2012