[Issue 18790] New: can't put a const(char)[] into a char[]

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 21 22:32:56 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18790

          Issue ID: 18790
           Summary: can't put a const(char)[] into a char[]
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at yahoo.com

The most basic string output range is char[]. Why can't I put a string in
there?

auto buf = new char[100];

put(buf, "hello"); // static assert: "Cannot put a string into a char[]."

I found this because I'm trying to write to a stack buffer string to use later
using formattedWrite.

The answer to my question is (as usual) auto-decoding. ugh.

At the very least, the message should be clearer (obviously, we can put a
string into a char[]!).

--


More information about the Digitalmars-d-bugs mailing list