The function in question is std.algorithm.searching's until .
Here are the definitions:
Until!(pred, Range, Sentinel)
until(alias pred = "a == b", Range, Sentinel)
(Range range, Sentinel sentinel, OpenRight openRight =
if (!is(Sentinel == OpenRight));
Until!(pred, Range, void)
until(alias pred, Range)
(Range range, OpenRight openRight = OpenRight.yes);
Now the first thing that came to mind was that it seemed odd to
have openRight be a runtime flag instead of a compile-time flag.
But that didn't hinder my usage of it, so I went ahead and called
the function like so:
range.until!(e => e > f)(No.openRight)
and I got an error saying the function could not be deduced, so I
went looking in the source code and found:
But I had assumed OpenRight was an alias for a Flag type , so
I had called it wrong.
Does anyone have any idea why the function is defined this way?
1. Why is openRight a runtime flag? Is there really a use case
2. Why is openRight not a Flag type?
here is the definition I was expecting:
alias OpenRight = Flag!"openRight";
auto until(alias pred = "a == b", OpenRight openRight =
Yes.openRight, Range, Sentinel)
(Range range, Sentinel sentinel);
auto until(alias pred, OpenRight openRight = Yes.openRight)(Range