How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
Hi,everyone, In C++, _T can guarantee that when converting from ascii encoding type to unicode encoding type, the program does not need to be modified. What do I need to do in D? Thanks.

Re: How to ensure string compatibility In D?

2019-01-22 Thread Olivier Pisano via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 13:55:30 UTC, FrankLike wrote: Hi,everyone, In C++, _T can guarantee that when converting from ascii encoding type to unicode encoding type, the program does not need to be modified. What do I need to do in D? Thanks. Hi, _T is not relevant to C++, but to W

How to use core.atomic.cas with (function) pointers?

2019-01-22 Thread Johan Engelen via Digitalmars-d-learn
The following code compiles: ``` alias T = shared(int)*; shared T a; shared T b; shared T c; void foo() { import core.atomic: cas; cas(&a, b, c); } ``` The type of T has to be a pointer to a shared int (you get a template match error for `cas` if `T = int*`), which is annoying but I k

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 14:07:48 UTC, Olivier Pisano wrote: On Tuesday, 22 January 2019 at 13:55:30 UTC, FrankLike wrote: In D, there is only Unicode. The language doesn't manipulate strings encoded in Windows local code-pages. For example: std::wstring strTest(_T("d://")); UINT nR

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 16:13:57 UTC, FrankLike wrote: On Tuesday, 22 January 2019 at 14:07:48 UTC, Olivier Pisano wrote: Some error is in "core.sys.windows.windows"? Thank you.

Re: How to ensure string compatibility In D?

2019-01-22 Thread Adam D. Ruppe via Digitalmars-d-learn
Use "mystring"w, notice the w after the closing quote.

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe wrote: Use "mystring"w, notice the w after the closing quote. "GetDriveType" Function is auto work by "_T" in C++,but how to do in D?

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe wrote: Use "mystring"w, notice the w after the closing quote. Or toStringz is not work like c_str() in C++?

Re: How to ensure string compatibility In D?

2019-01-22 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 16:47:45 UTC, FrankLike wrote: On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe wrote: Use "mystring"w, notice the w after the closing quote. Or toStringz is not work like c_str() in C++? stringz creates a char* but you need a wchar*

Re: How to ensure string compatibility In D?

2019-01-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 22, 2019 12:05:32 PM MST Stefan Koch via Digitalmars-d- learn wrote: > On Tuesday, 22 January 2019 at 16:47:45 UTC, FrankLike wrote: > > On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe > > > > wrote: > >> Use "mystring"w, notice the w after the closing quote. > > > >

Re: How to ensure string compatibility In D?

2019-01-22 Thread bauss via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 19:14:43 UTC, Jonathan M Davis wrote: On Tuesday, January 22, 2019 12:05:32 PM MST Stefan Koch via Digitalmars-d- learn wrote: On Tuesday, 22 January 2019 at 16:47:45 UTC, FrankLike wrote: > On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe > > wrote: >> U

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
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 ge

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
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 ge

Re: How to use core.atomic.cas with (function) pointers?

2019-01-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 14:13:23 UTC, Johan Engelen wrote: The following code compiles: ``` alias T = shared(int)*; shared T a; shared T b; shared T c; void foo() { import core.atomic: cas; cas(&a, b, c); } ``` The type of T has to be a pointer to a shared int (you get a templa

Re: How to use core.atomic.cas with (function) pointers?

2019-01-22 Thread Kagamin via Digitalmars-d-learn
I believe this is historical. It will fail because atomics are combinatorially parameterized because the compiler couldn't properly infer template arguments until recently (this also resulted in memory corruption in ldc fork of druntime). Now that the compiler was fixed, atomics can be fixed to