Why implicit conversion of string literal to char[] does not works?
John Colvin
john.loughran.colvin at gmail.com
Tue Jul 2 03:09:09 PDT 2013
On Tuesday, 2 July 2013 at 09:11:44 UTC, Michal Minich wrote:
> Sorry for posting to announce.
In future please post these questions to digitalmars.D.learn
The reason you can't implicitly convert a string to a char[] is
because string is an alias to immutable(char)[]
Therefore, you would be providing a mutable window to immutable
data, which is disallowed unless you *explicitly* ask for it (see
below).
You can explicitly cast string to char[], but it is undefined
behaviour to modify the contents of the result (i.e. don't cast
away immutable unless you absolutely have to and even then be
very very careful).
More information about the Digitalmars-d-announce
mailing list