On 19.12.2015 01:06, Fer22f wrote:
Documentation on casts say:
Casting a pointer type to and from a class type is done as a type paint
(i.e. a reinterpret cast).
That sentence doesn't apply. string is not a class, it's an alias for
immutable(char)[], i.e. it's an array.
Reinterpretation is rather dangerous if strings are stored differently.
But this test gives me a good hope on this case:
writeln(*(cast(char*) "Test"));
Casting is what I'm going with. .dup.ptr is less clear in this case.
Correctness beats clarity.
I'd like to advise you not to use casts unless you know for sure that
they're safe.
Here, you need to know what a string is exactly, what the cast does
exactly, and what exactly the called function does with the pointer.