digitalmars.D - String matching both char & wchar in std.stream.stdout.write
- Kramer (10/10) Mar 03 2005 For the following code:
- Regan Heath (18/29) Mar 03 2005 Yes.
For the following code: #import std.stream; #void main() I get this error: StreamWriteTest.d(5): function std.stream.Stream.write overloads void(char[]s) and void(wchar[]s) both match argument list for write Is there a clean way to fix this? Do I have to cast this string? -Kramer
Mar 03 2005
On Thu, 3 Mar 2005 22:48:24 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:For the following code: #import std.stream; #void main() I get this error: StreamWriteTest.d(5): function std.stream.Stream.write overloads void(char[]s) and void(wchar[]s) both match argument list for write Is there a clean way to fix this? Do I have to cast this string?Yes. Possible solutions (previously suggested) 0- Do nothing, cast is sufficient. 1- Allowing a prefix to the string i.e.(denoting that it's a wchar) 2- Where collisions occur assume a literal string is char[]. 3- Decide the type based on the contents. I have no problem with (0), (1) is simply another way to express the same thing which is the programmer stating "this literal is an x[]". (2) might have hidden bug consequences in the (unlikely?) event there are 2 functions of the same name taking different char types, doing different tasks. (3) is like (2) except it's additionally optimisation, after all UTF-8, 16, and 32 can all represent all the information, they just do it with differing byte usage. Regan
Mar 03 2005