Fetching an element using find
Steven Schveighoffer
schveiguy at gmail.com
Mon Jan 13 17:58:57 UTC 2020
On 1/13/20 12:47 PM, H. S. Teoh wrote:
>
> Why not write your own convenience wrapper?
>
> auto firstElement(R)(R r)
> if (isInputRange!R)
> {
> if (r.empty) throw new Exception(...);
> return r.front;
> }
>
> auto e = myData.find!(e => blah(e)).firstElement;
I certainly can (and did). I was wondering if there was something in
Phobos to do it.
-Steve
More information about the Digitalmars-d-learn
mailing list