Fixing std.string
Simen kjaeraas
simen.kjaras at gmail.com
Tue Aug 24 01:42:17 PDT 2010
Norbert Nemec <Norbert at nemec-online.de> wrote:
> On 20/08/10 03:22, dsimcha wrote:
>> 3. Is there any good reason to avoid just templating everything to
>> work with
>> all 9 string types (mutable/const/immutable char/wchar/dchar[]) or
>> whatever
>> subset is reasonable for the given function?
>
> Wouldn't it be sufficient to take const as input? IIRC, both mutable and
> immutable can be implicitly converted to const and this exactly the
> purpose that const is designed for: data that I can't change but that
> other code may be able to change. Or am I mixing something up here?
What should the functions return, then? If the output is always
const(char)[], I need to cast it to make it immutable(char)[] or char[],
and casting is an unsafe operation.
--
Simen
More information about the Digitalmars-d
mailing list