++Phobos

Meta jared771 at gmail.com
Thu Oct 17 21:24:15 UTC 2019


On Thursday, 17 October 2019 at 20:50:54 UTC, jmh530 wrote:
> On Thursday, 17 October 2019 at 19:37:38 UTC, Meta wrote:
>> [snip]
>>
>> Correct me if I'm wrong, but would using this with std.range 
>> be as simple as:
>>
>> import std.range;
>>
>> @implements!(MyCoolRange, InputRange)
>> struct MyCoolRange(T)
>> {
>>     ....
>> }
>>
>> long sum(R)(R range)
>> if (implements!(R, InputRange))
>> {
>>     ....
>> }
>
> implements is for an interface. You would actually use models 
> (with the isInputRange from the concepts library, not phobos), 
> so change
> @implements!(MyCoolRange, InputRange)
> to
> @models!(MyCoolRange, isInputRange)
> and you don't need models for below, just change
> if (implements!(R, InputRange))
> to
> if (isInputRange!R)
> but make sure you are using the one from the concepts library.

I'm referring to the InputRange et al. interfaces from 
std.range.interfaces:
https://dlang.org/phobos/std_range_interfaces.html


More information about the Digitalmars-d mailing list