www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9518] New: With DList of pointers, insertBack matches multiple templates.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9518

           Summary: With DList of pointers, insertBack matches multiple
                    templates.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: entheh cantab.net



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.
:)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 16 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9518




I meant of course:

list.back = &struct;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 16 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9518


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 9539 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2013