[Issue 13544] calls to std.file.FileException are idup-ing their string arguments

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Sep 27 19:24:38 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13544

Vladimir Panteleev <thecybershadow at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow at gmail.com

--- Comment #2 from Vladimir Panteleev <thecybershadow at gmail.com> ---
(In reply to Walter Bright from comment #0)
> The signature for functions like std.file.copy() takes "in char[]" so it can
> be called with both mutable and immutable strings. If an exception gets
> thrown, the conservative assumption is that the source may get changed
> so the string is duplicated.
> 
> The problem, again, is bloat.
> 
> The solution is to add two overloads for FileException, one taking string
> and one taking const(char)[].

Doesn't that mean that we'd also need to add overloads to std.file.copy (and
many other std.file functions)?

(In reply to hsteoh from comment #1)
> A better solution is to use to!string, which is a no-op if the source and
> destination types are identical.

That won't work for "in char[]", will it? It would only work by making the
constructor templated.

--


More information about the Digitalmars-d-bugs mailing list