On Tuesday, 22 January 2019 at 21:49:00 UTC, bauss wrote:
On Tuesday, 22 January 2019 at 19:14:43 UTC, Jonathan M Davis

Is there a reason we cannot implement toStringz like:

immutable(TChar)* toStringz(TChar = char)(scope const(TChar)[] s) @trusted pure nothrow;
// Couldn't find a way to get the char type of a string, so

couldn't make the following generic:
immutable(char)* toStringz(return scope string s) @trusted pure nothrow; immutable(wchar)* toStringz(return scope wstring s) @trusted pure nothrow; immutable(dchar)* toStringz(return scope dstring s) @trusted pure nothrow;

For example:
///////////////////////////////////start///////////////////////////////////
import core.sys.windows.windows;
import std.stdio;
import std.string;
import std.conv;

void main()
{
        auto    strA_Z ="CD"w;
        auto type = GetDriveType(tos(to!wstring(strA_Z[0])~":\\"));
        writeln(to!wstring(strA_Z[0])~" is ",type);
}

private auto tos(T)(T str)
{
 version (ANSI)
 {
        writeln("ANSI");
        return cast(const(char)*)(str);
 }
 else
 {
        writeln("Unicode");
        return cast(const(wchar)*)(str);
        
 }
}
///////////////////////////////end/////////////////////////////
It's work ok.

Reply via email to