Why foreach(c; someString) must yield dchar

Steven Schveighoffer schveiguy at yahoo.com
Mon Aug 23 04:51:06 PDT 2010


On Thu, 19 Aug 2010 10:34:01 -0400, dsimcha <dsimcha at yahoo.com> wrote:

> == Quote from Kagamin (spam at here.lot)'s article
>> dsimcha Wrote:
>> > Hmm, lately I've been focusing my hacking efforts on  
>> debugging/polishing/removing
>> > annoying inconsistencies in Phobos.  Maybe std.string should be my  
>> next target.
>> > It's generally a frustrating module because in addition to the wide  
>> character
>> > issue, lots of stuff requires immutable strings when it could work  
>> correctly and
>> > safely with a const or mutable string.
>> They say, there're bugs with inout. You don't need them fixed?
>
> No.  inout is only important where you can't/don't want to use  
> templates.  This is
> the case if you're concerned about code bloat, or need virtual  
> functions.  In
> std.string, not only **can** I use templates, I **have to** use them to  
> deal with
> narrow vs. wide strings.

No no, inout is essential on templates as well.  e.g.:

inout(T) min(T)(inout(T) t1, inout(T) t2)
{
    return t2 < t1 ? t2 : t1;
}

-Steve


More information about the Digitalmars-d mailing list