C++ guys hate static_if?

Timon Gehr timon.gehr at gmx.ch
Sat Mar 9 10:38:49 PST 2013


On 03/09/2013 01:48 AM, DypthroposTheImposter wrote:
>         See the static_if paper here:
>
> http://isocpp.org/forums
>
> Under the post "constraints and static if" there is a link to a
> document about
> static_if
>
> https://docs.google.com/viewer?a=v&pid=forums&srcid=MDIyMDc3NjUwMTczOTM0Mjk3NjABMDI2MzM3MjkxNDM4NDQ5MzE4NDcBLWVsS1Y4dFhtdDhKATUBaXNvY3BwLm9yZwF2Mg
>
>
>        Are they full of it?

Maybe. The paper is full of typos.

> Has it caused the problems they mention in D?

All of the non-C++ specific ones that are not made up to make the paper 
longer. Eg:

0. Templates + static if are an ad-hoc abstraction mechanism.

1. Declaration-site template body type checking becomes undecidable.

2. Constraint-based overloading needs manual work in order to express 
specialization relations.


In D there also exist other problems that wouldn't occur in C++ in that 
form:

static if(!is(typeof(x))) enum y = 1;
static if(!is(typeof(y))) enum z = 2;
static if(!is(typeof(z))) enum x = 3;

The above currently does not have any defined behaviour. If the three 
are distributed to mutually importing modules, which constants get 
defined may depend on the order the modules are passed to DMD on the 
command line. (It is solvable, but so far few people have shown interest.)



More information about the Digitalmars-d mailing list