March 08, 2008 D2 opAssign conflict | ||||
---|---|---|---|---|
| ||||
In the latest D2 release, if a struct implements a destructor, the compiler automatically defines an opAssign. Unfortunately this causes conflicts with user-defined, templated opAssigns. struct Value { void opAssign(T)(T value) {} ~this() {} } Error: function Value.opAssign conflicts with template Value.opAssign(T) The first opAssign in the error message is the compiler-generated one. If I define multiple non-templated opAssigns, the problem goes away - shouldn't we be allowed to have it both ways? John. |
March 08, 2008 Re: D2 opAssign conflict | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C | "John C" <johnch_atms@hotmail.com> wrote in message news:fqufog$2ncd$1@digitalmars.com... > In the latest D2 release, if a struct implements a destructor, the compiler automatically defines an opAssign. Unfortunately this causes conflicts with user-defined, templated opAssigns. > > struct Value { > > void opAssign(T)(T value) {} > > ~this() {} > > } > > Error: function Value.opAssign conflicts with template Value.opAssign(T) > > The first opAssign in the error message is the compiler-generated one. If I define multiple non-templated opAssigns, the problem goes away - shouldn't we be allowed to have it both ways? > > John. Template functions and regular functions are supposed to overload agains each other in D2, but I'm not sure if that's implemented yet. If/when it's implemented I'd imagine that it'd work. |
Copyright © 1999-2021 by the D Language Foundation