[Issue 6547] Call to std.algorithm.remove causes compile error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 16 03:25:44 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6547


Yuri Gorobets <yuri.gorobets at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yuri.gorobets at gmail.com


--- Comment #1 from Yuri Gorobets <yuri.gorobets at gmail.com> 2012-02-16 03:25:32 PST ---
(In reply to comment #0)

This behavior appears to be as designed. The compilation problem is caused by
special treatment of the "narrow strings" by std.array:

http://dlang.org/glossary.html#narrow%20strings

import std.array;
import std.algorithm;

void main()
{
    char[] s = "narrow".dup;

    s.remove(0); // Error: template std.algorithm.move(T) 
                 // does not match any function template declaration
                 // Error: template std.algorithm.move(T) cannot deduce 
                 // template function from argument types !()(dchar,dchar)

    // remove troubles are caused by the special treatment of narrow strings
    // front(s) doesn't return a char reference but dchar value instead:
    s.front = 'c';    // Error: s.front is not an lvalue
}

dchar version works fine:

void main()
{
    dchar[] u = "unicode"d.dup;
    u.remove(0);    // works fine
    u.front = 'c';
}

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


More information about the Digitalmars-d-bugs mailing list