July 17, 2006 Bug related to operators and namespaces | ||||
---|---|---|---|---|
| ||||
Hi, The code below is rejected by version 8.48 of the Digital Mars compiler; it is accepted by Borland, Visual and Comeau and (most important) it looks valid to me :) Maybe the definition of operator+ should be searched for in the current namespace too, not only in the namespaces of the operands... ----------------------------------------------------- Cut here namespace N1 { class X { int _i; }; } namespace N2 { N1::X operator+ (const N1::X &x1, const N1::X &x2) { return x1; } void Test () { N1::X x; operator+ (x, x); // works x + x; // fails } } int main () { return 0; } ----------------------------------------------------- and here The error message is: x + x; ^ main.cpp(22) : Error: illegal operand types Had: N1::X and: N1::X -- Yours truly, Adder |
Copyright © 1999-2021 by the D Language Foundation