On 08/03/12 02:04, Nathan Ridge wrote:
[any.hpp mysterious false?exp1:exp2 expr]:
In any.hpp, there's several expressions like:
false? this->_boost_type_erasure_deduce_constructor(arg...) : 0
Since:
false?exp1:exp2
always evaluates to exp2, this just obscures the code. It should be replaced with exp2(i.e. 0) or some in-source comment attached explaining why the ?: operator is needed.
This use of the conditional operator is a technique to determine the type of an expression without evaluating it. In this case, "arg..." will never be evaluated (since it appears in a false branch of a conditional expression), but its type will influence the type of the entire conditional expression.
Eric Niebler explains this technique nicely in this article [1] (see page 2 in particular).
Regards, Nate
THANK YOU! If any.hpp had used a macro, somewhat like the ENCODED_TYPEOF shown here: http://www.artima.com/cppsource/foreach2.html including the comments explaining the purpose, the code would have been easier to understand. -regards, Larry with either the