www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9016] New: swap() doesn't work with std.container.DList.front and back


           Summary: swap() doesn't work with std.container.DList.front and
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc

--- Comment #0 from bearophile_hugs eml.cc 2012-11-12 20:31:03 PST ---
std.container.DList supports a manually written swap of its front and back
items, but it seems std.algorithm.swap() on them is not supported:

import std.stdio, std.algorithm, std.container;
void main() {
    auto L = DList!int([10, 20, 30]);
    writeln(L[]); // [10, 20, 30]
    auto aux = L.front;
    L.front = L.back;
    L.back = aux;
    writeln(L[]); // [30, 20, 10]
    //swap(L.front, L.back);

If you uncomment the swap dmd 2.061alpha gives:

test.d(9): Error: template std.algorithm.swap does not match any function
template declaration
...\dmd2\src\phobos\std\algorithm.d(1767): Error: template std.algorithm.swap
cannot deduce template function from argument types !()(int,int)

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 12 2012