Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2006-07-06 04:35:30


On Wed, 05 Jul 2006 18:05:20 +0200, Gennaro Prota
<gennaro_prota_at_[hidden]> wrote:

>On Wed, 5 Jul 2006 18:20:57 +0300, "Peter Dimov" <pdimov_at_[hidden]>
>wrote:
>
>>BOOST_ASSERT wasn't supposed to be an improvement over assert,
>>interface-wise. In my opinion, invalid assertions should be fixed; we should
>>not alter BOOST_ASSERT to make them work.
>
>I agree. The point, anyhow, was avoiding those invalid assertions.
>What I proposed above make them silently work as the user expects
>without invoking undefined behavior. The alternative is *catching* the
>error. If we can do the latter then it's even better to me.

Just to spell out what I have in mind and make a couple of further
questions (:-s):

  namespace boost {
    namespace detail { namespace assert_ {

    char valid_assert_expression(int);
    void valid_assert_expression(...);
  }}}

  #define BOOST_ASSERT(expr) \
    ( \
      (void)sizeof boost::detail::assert_ \
                    ::valid_assert_expression(expr) \
      , assert(expr) \
    ) /**/

Now I wonder:

a) should we leave the test when BOOST_DISABLE_ASSERTS is defined too?

b) why the last parameter of assertion_failed() is not unsigned long?

--
[ Gennaro Prota, C++ developer for hire ]
[    resume:  available on request      ]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk