D-Programming-Language/phobos — pull request #1407 by monarchdodra (2013-07-10 15:36:43+00:00)
Title: Fix DirEntry string construction and CopyContruction

Long overdue fix for DirEntry.
http://forum.dlang.org/thread/xshpyflzrrtkftwtghdp@forum.dlang.org
(no bug report filed, I'll do it later)

Basically, writing `auto a = DirEntry("name")` did not work, because `DirEntry` did not have a constructor. The "correct" way to write it was `auto a = dirEntry("name")` (notice the caps).

I decided to "fix" this by giving DirEntry a constructor. Another option is to make `DirEntry` private/disabled constructors, and FORCE usage of `dirEntry` (a valid solution too).

This also fixes a (very) nasty bug where writing:
```D
DirEntry a = dirEntry("Path");
auto b = DirEntry(a);
```

Again, what this actually does is implicitly cast a to string, and then (non)-construct b from the string (eg, non-constructed and not useable). Writing it that way is stupid, and I doubt anybody does it, so this fix just prevents that (no constructor taking a DirEntry). It was actually a *very* nasty bug, because our (broken)* emplace tested `T(args)` in one of its branches. Because of this emplacing a DirEntry is currently completely broken (Took me a couple of hours to understand this). The consequence is that using DirEntry in array/appender/Array (or anything else that is low level and emplaces) broke*

@jmdavis : Do you want to review this? I changed the strict necessary to get it working. Any input for better ways to fix this is welcome.

--------------------------------
*: Shameless plug: My emplace fix (#1082) correctly handled DirEntry's "copy construction", even with its broken mechanics.