Summary: to!() fails with static arrays
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos

--- Comment #0 from Jonathan M Davis <> 2010-10-01 22:54:00 
PDT ---
This code fails to compile

import std.conv;
import std.stdio;

void main()
    dchar[7] numStr = "1234567";


with this error

Error: template std.conv.toImpl(T,S) if (!implicitlyConverts!(S,T) &&
isSomeString!(T) && isInputRange!(Unqual!(S)) && isSomeChar!(ElementType!(S)))
toImpl(T,S) if (!implicitlyConverts!(S,T) && isSomeString!(T) &&
isInputRange!(Unqual!(S)) && isSomeChar!(ElementType!(S))) matches more than
one template declaration,
if (isStaticArray!(S)) and
if ((is(S : const(wchar)[]) || is(S : const(dchar)[])) && !isSomeString!(T))

If you use numStr[] instead of numStr, it works. But I see no reason why to!()
can't be made to work with a static array. Ideally, it would either turn it
into a const ref or a dynamic slice itself, thus avoiding creating a copy, but
right now it just fails. Maybe that's just how things go with static arrays,
but it seems overly restrictive in this case. to!() shouldn't _need_ a
dynamically allocated array.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to