Boost logo

Boost :

From: Eric Woodruff (Eric.Woodruff_at_[hidden])
Date: 2002-10-19 10:21:37


"If cond expands to 0, this macro causes a preprocessing error. Otherwise,
it expands to nothing. "

How can a static assertion guard against a value that varies at runtime?

"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:001101c27781$acb08010$1d00a8c0_at_pdimov2...
> From: "Daniel Frey" <d.frey_at_[hidden]>
> > Hi,
> >
> > I have a (maybe dumb) question. The current version of shared_ptr
contains
> code
> > like:
> >
> > typename detail::shared_ptr_traits<T>::reference operator* () const //
> never throws
> > {
> > BOOST_ASSERT(px != 0);
> > return *px;
> > }
> >
> > What does "never throws" means
>
> It means that operator* doesn't throw when its requirements ("The stored
> pointer must not be 0") are met, otherwise the behavior is undefined.
>
> > ... wrt BOOST_ASSERT?
>
> BOOST_ASSERT(px != 0) must not throw when px != 0.
>
> > Isn't this a contradiction?
>
> No. :-)
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>


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