C++ guys hate static_if?

Era Scarecrow rtcvb32 at yahoo.com
Sun Mar 10 21:38:51 PDT 2013

On Monday, 11 March 2013 at 02:39:47 UTC, Jonathan M Davis wrote:
> I haven't read the paper, so I really don't know what problems 
> they see with static if, and C++ _is_ a very different beast 
> than D (particularly with regards to stuff done at compile 
> time), but without statif if, C++ seems very crippled with 
> regards to templates and conditional compilaton. The 
> combination of template constraints and static ifs is 
> _extremely_ powerful in D, and it works very well. C++ 
> currently lacks anything of the sort, and until it does, it's 
> templates will be very much inferior to D's. Maybe they can 
> gain similar power through different mechanisms, but I'm 
> surprised that anyone would think that static if was such a bad 
> idea. It's working fantastically well for us, and I don't know 
> how we'd get along without it.

  It basically comes down to syntactical analysis, being able to 
tell if code is written right (when blocks end as well), which 
goes with their templates and use of <>'s; Which I'm glad to see 
D isn't crippled in that way.

  The another part is how static if becomes 'viral' as you'd have 
to use 'static if' in every spot elsewhere in order to keep it in 
line; However the example shown is bad programming practice and; 
You can duplicate very easily using the preprocessor.

  A third part of it was how 'verbose' they would have to be to 
check constraints, but with how just before C++11 they were 
verbose everywhere, so why it is verbose in constraints as his 
problem I am not sure.

More information about the Digitalmars-d mailing list