C++ guys hate static_if?

deadalnix deadalnix at gmail.com
Tue Mar 12 00:19:35 PDT 2013


On Tuesday, 12 March 2013 at 07:10:36 UTC, Andrej Mitrovic wrote:
> On 3/12/13, deadalnix <deadalnix at gmail.com> wrote:
>> Concepts are for instance THE perfect match for all kind of 
>> range
>> we have.
>
> I don't know about that. Consider that with template parameters 
> and
> static if you can pick and choose which range type you will 
> implement:
>
> struct Range(Store)
> {
>     static if (hasLength!Store)
>     {
>         // implement length, make the range random-access
>     }
>     else
>     {
>         // make the range an input range
>     }
> }
>
> How would you implement this with concepts if you have to put 
> the list
> of implements at the struct header?

I was thinking about constraint. I don't think static if should 
go away in any way.


More information about the Digitalmars-d mailing list