C++ guys hate static_if?

Nick Treleaven ntrel-public at yahoo.co.uk
Mon Mar 11 10:56:34 PDT 2013


On 09/03/2013 11:15, Artur Skawina wrote:
> Seriously though, they point out several problems, some of which are C++
> context specific (like mixing CPP w/ static-if and lack of introspection).
> Other mentioned issues are not real problems in practice, or not even
> problems at all.
>
> What's left is:
>   - static-if not creating scopes/is/  confusing, but what would be a better
>     alternative?

Isn't it only confusing to newbies? It's not hard to learn and recognize.

>   - (static-)if in templates or as template constraints -
>      a) prevents pre-instantiation verification - true, applies to D, but
>           not really a big problem, assuming sane application of static-if,

Maybe a concept-based static if would work for C++? That would allow 
pre-instantiation verification, but still allow flexible code. The 
concept test would only allow concept features within the static if branch.

>      b) make constraint-based overloading ugly and fragile - true, something
>           better is needed for D too. But until that exists, careful use
>           of constraints mostly works.



More information about the Digitalmars-d mailing list