Shouldn't hasSwappableElements work on char arrays?

Jesse Phillips jessekphillips+D at gmail.com
Thu Feb 24 13:13:00 PST 2011


Andrej Mitrovic Wrote:

> Yes. And you know what's going to happen next, right? Everyone is
> going to create their own implementation of a string type because of
> these non-issues. Happens in C/C++ all the time, I see it in almost
> every mid-large codebase out there.

Well, aside from discussions to create a proper string type, Text in Tango and mText on dprogramming.org I have yet to see people using a special string type.

I'm not sure why you are complaining that compiler is preventing you from doing something stupid. An array of char is not swappable, a range of char is not swappable. D is not in the habit of hiding complexity, trying to swap a string requires a conversion to dchar or at least handling a sequence of char so it is best to state that is what is happening in the code.


More information about the Digitalmars-d mailing list