Convert a single element into a range
A Guy With a Question
aguywithanquestion at gmail.com
Thu Nov 30 23:08:13 UTC 2017
On Thursday, 30 November 2017 at 22:52:33 UTC, Ali Çehreli wrote:
> On 11/30/2017 02:47 PM, A Guy With a Question wrote:
>> This is probably a dumb question, but what I did looks ugly.
>> Is there a way (preferably a one liner) to convert a single
>> element, like an int or char or bool, into a range?
>
> import std.range;
>
> void main() {
> auto r = only(42);
> static assert(isInputRange!(typeof(r)));
> }
>
> Ali
Excellent!
More information about the Digitalmars-d-learn
mailing list