Changing the behavior of compile time ? :

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Tue May 8 11:18:44 PDT 2007


One thing that has been bugging me for a while is that the behavior of the
ternary ? : operator. On runtime

auto foo = c() ? a() : b();

first evaluates c(), then only either a() or b(), not both of them. But, on
compile time they are all evaluated.

I'm aware that some template code depends on the behavior of ? : to deduce
the proper type of the expression, but does it always require evaluation of
both branches? Could it just deduce the type without instantiating
templates etc. ?

Changing this would make the template code readable in many places (static
if's and helper templates could be converted to a one liner), and the old
behavior could be simulated in many cases with helper variables.



More information about the Digitalmars-d mailing list