Subject: Re: [boost] [Boost.Test] Assertion changes in trunk? [WAS: Call for Review: Boost.Test documentation rewrite]
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2014-01-22 08:05:11
On Wed, Jan 22, 2014 at 1:21 PM, Thorsten Ottosen <
> On 22-01-2014 13:11, Mathias Gaunard wrote:
>> On 22/01/14 11:52, Alexander Lamaison wrote:
>> BOOST_TEST(a <operator> b), however, cleverly parses a, b and <operator>
>>> from the macro and does something like
>>> bool x = (a <operator> b)
>>> BOOST_CHECK_MESSAGE_IMPL(x, "a must be <operator> to b", a, b);
>> What sort of magic allows to parse a <operator> b, and how reliable is
>> it in the real world?
> Completely reliable. You just bind the first object to some wrapper
> class object which provide the overloaded operators (via delegation).
This seems to rely on an op->* operator, which has lower precedence than
unary op* (dereference), and the macro INTERNAL_CATCH_TEST uses
un-parenthesized Catch::ExpressionDecomposer()->*expr, so won't this break
if I do MACRO(*lhs_ptr == *rhs_ptr)? I suppose MACRO((*lhs_ptr) ==
*rhs_ptr) might fix it, but the compile error for the obvious code might
come as a surprise to many, no?
I'm no C++ expert, so perhaps the above is nonsense, but I'd be interested
in more details as to how this technique can be completely reliable, as
stated by Thorsten. Thanks, --DD
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk