[Issue 15027] cannot pass arguments of type DirEntry to std.file functions

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Oct 8 23:48:52 PDT 2015


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

--- Comment #16 from Rainer Schuetze <r.sagitario at gmx.de> ---
Here is a version that overloads structs with alias this to a string range by
reference, avoiding the copy problem:

auto isDir(Range)(Range input)
    if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range))
{
    //...
}

auto isDir(Range)(ref Range input)
    if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range))
        && is(StringTypeOf!Range))
{
    return isDir(cast(StringTypeOf!Range) input);
}

--


More information about the Digitalmars-d-bugs mailing list