C++ guys hate static_if?

deadalnix deadalnix at gmail.com
Tue Mar 12 08:37:00 PDT 2013


On Tuesday, 12 March 2013 at 15:26:19 UTC, TommiT wrote:
>> With the thing defined that way not that much. But consider :
>>
>> concept InputRange(T) {
>>    bool empty;
>>    T front;
>>    void popFront();
>> }
>
> What if I write a type like the following:
>
> struct MyType {
>     int _value;
>
>     @property bool empty() const { return true; }
>     @property ref const(int) front() const { return _value; }
>     void popFront() const { }
> }
>
> Does MyType fulfill the requirements of your InputRange(T) 
> concept? I don't think it does since its front returns by ref 
> const(int) and InputRange(T)'s front returns by value.

It doesn't because popFront is const and that don't make any 
sense. But more generally, I wrote that stuff quickly to 
demonstrate what it could look like and not to provide an 
accurate definition of InputRange.


More information about the Digitalmars-d mailing list