digitalmars.D.learn - templates + operator overloading problem
i'm doing a lambda functions thing and I've got this class Lambda(T) { Ret2!(RHST).Ret opSub(RHST)(RHST rhs) { return Ret2!(RHST).opAdd(rhs); } Ret2!(RHST).Ret opSub_r(RHST)(RHST rhs) { return Ret2!(RHST).opAdd(rhs); } } i need to be able to accept an operand of any type on either side (for constants in expressions) unfortunately D says this is ambiguous and gives a compile error whenever I subtract Lambda from Lambda. i can specialise it for the case when it *is* Lambda, but i can't get rid of the need for a catch all for the constants. i can't see any way around this? is there? BC
Dec 08 2007
On Sat, 08 Dec 2007 19:28:44 -0000, BC <NOTmi_emayl_adrez hotmail.com.remove.not> wrote:i'm doing a lambda functions thing and I've got this class Lambda(T) { Ret2!(RHST).Ret opSub(RHST)(RHST rhs) { return Ret2!(RHST).opAdd(rhs); } Ret2!(RHST).Ret opSub_r(RHST)(RHST rhs) { return Ret2!(RHST).opAdd(rhs); } } i need to be able to accept an operand of any type on either side (for constants in expressions) unfortunately D says this is ambiguous and gives a compile error whenever I subtract Lambda from Lambda. i can specialise it for the case when it *is* Lambda, but i can't get rid of the need for a catch all for the constants. i can't see any way around this? is there? BCis it me causing these extra posts? i guess it must be. oops
Dec 08 2007