[Issue 22002] std.algorithm.each breaks when used with InputRangeObject

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 18 07:38:31 UTC 2021


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

--- Comment #1 from mipri <mipri at minimaltype.com> ---
workaround:

auto noapply(T)(T x) {
    import std.range.primitives : ElementType;

    struct NoApply(T) {
        T wrapped;
        alias wrapped this;
        @disable ElementType!T opApply();
    }
    return NoApply!T(x);
}

unittest {
    import std.algorithm : each;
    import std.range : only, inputRangeObject;
    import std.stdio : writeln;

    only(1, 2).inputRangeObject.noapply.each!writeln;
}

--


More information about the Digitalmars-d-bugs mailing list