www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18790] New: can't put a const(char)[] into a char[]


          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 puremagic.com
          Reporter: schveiguy yahoo.com

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

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[]!).

Apr 21 2018