On 09/20/2011 08:34 PM, Trass3r wrote:
Are you sure that the call requires the string to be null terminated? I do not know that winapi function, but this might work:bool test(HDC dc, string str, SIZE* s) { auto wstr = to!(wchar[])str; GetTextExtentPoint32W(dc, wstr.ptr, wstr.length, s); ...It doesn't need to be null-terminated for that function. Shouldn't you use to!wstring though?!
It has to be copied anyway, so there is no real difference. I just did not know the signature of that function, and if it had been missing the const, wstring would not have worked. But if there is a const, wstring is indeed superior because shorter and clearer.
