Deprecating things without a replacement
KennyTM~
kennytm at gmail.com
Sun Jul 17 09:16:16 PDT 2011
On Jul 17, 11 23:28, Robert Clipsham wrote:
> Also note that you can't use dirEntries() ~ dirEntries() or
> chain(dirEntries(), dirEntries()) as DirIterator is not a range.
This compiles and runs for me:
-----------------------------------
import std.file, std.range, std.algorithm, std.stdio;
void main() {
auto dFiles = filter!`endsWith(a.name, ".d")`(dirEntries(".",
SpanMode.depth));
auto cFiles = filter!`endsWith(a.name, ".c")`(dirEntries("./foo",
SpanMode.depth));
foreach (file; chain(dFiles, cFiles)) {
writeln(file.name);
}
}
-----------------------------------
The problem is *not* DirIterator not being a range, but that DirIterator
is not a range of *string*. The foreach loop you're using
foreach (string file; obj) { ... }
requires an *opApply* which outputs strings from 'obj', but the range
interface of 'DirIterator' outputs 'DirEntry'.
More information about the Digitalmars-d
mailing list