Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2000-11-09 13:23:51


From: Beman Dawes <beman_at_[hidden]>
> John Maddock wrote:
>
> >Beman,
> >
> >>Perhaps I should just work on a core proposal for a new language
> >>feature. All of the macro uses we are talking about are needed to get
> >>__FILE__ and __LINE__. How about two new special symbols:
> >>
> >>namespace boost {
> >> static_assert( bool exp, const char * file=__FILE_AT_USE,
> >> int line=__LINE_AT_USE );
> >>}
> >>
> >>The compiler is required to replace these with the appropriate value at
> >the
> >>point of a call to static_assert(), rather than at point of declaration.
> >
> >If this were going forward as part of the standard I would say yes call
> in
> >"static_assert" and place it <cassert>, either as a regular macro, or as
> a
> >core language extention (depending how the vendor sees it).
> >
> >However, there is a problem with your approach wrt boost: how does the
> >static_assert function you've defined above, convert the bool parameter
> to
> >a static assertion (as an integral constant expression)?
>
> I don't know without language support. It keeps coming back to that; there
> needs to be better language support for diagnostic tools.
>
> __FILE_AT_USE and __LINE_AT_USE would allow some better user written tools
> like various improved runtime asserts, so they wouldn't be be totally
> useless. I'm just trying to provoke thought, not actually present a
> finished solution.

I recall that my proposal for a similar __WHERE__ macro was not well received.

Another related problem is that using the assert macro in inline code can
easily lead to violations of the One Definition Rule.


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