Bug 9518 – With DList of pointers, insertBack matches multiple templates.
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-16T05:46:00Z
Last change time
2013-04-10T22:01:32Z
Assigned to
nobody
Creator
entheh
Comments
Comment #0 by entheh — 2013-02-16T05:46:31Z
For example:
struct STRUCT {
int field;
}
DList!(STRUCT*) list;
STRUCT struct;
//This works:
list.insertBack(null);
list.back=struct;
//This doesn't:
list.insertBack(&struct);
The error is along the lines of:
Error: template std.container.DList!(STRUCT*).DList.insertBeforeNode matches more than one template declaration, C:\D\dmd2\windows\bin\..\..\src\phobos\std\container.d(2054):insertBeforeNode(Stuff)(Node* n, Stuff stuff) if (isInputRange!(Stuff) && isImplicitlyConvertible!(ElementType!(Stuff), T)) and C:\D\dmd2\windows\bin\..\..\src\phobos\std\container.d(2113):insertBeforeNode(Stuff)(Node* n, Stuff stuff) if (isImplicitlyConvertible!(Stuff, T))
Looks as if it accidentally matches the range-adding insertBack function as well as the single-entry-adding function.
(I haven't directly tested this example - I just encountered it in a bigger project. Apologies if I've got something wrong in the example.)
I don't know enough about the stuff involved to fix this. Hopefully someone who knows D better can figure out a good fix, either in the compiler or in Phobos. :)
Comment #1 by entheh — 2013-02-16T05:47:53Z
I meant of course:
list.back = &struct;
Comment #2 by k.hara.pg — 2013-04-10T22:01:32Z
*** This issue has been marked as a duplicate of issue 9539 ***