Topic: Standardize (BOOST_)STATIC_ASSERT


Author: Alberto Barbati <AlbertoBarbati@libero.it>
Date: Fri, 6 May 2005 14:59:56 CST
Raw View
Hi Everybody,

this post has been triggered by Samee Zahur post about error messages,
but I thought it might deserve a separate thread.

The subject says it all: standardizing a facility like
BOOST_STATIC_ASSERT. The advantages of a that are apparent: as a tool,
it has been extensively used, it's simple to implement and a lot of
programmers seem to be using their own equivalent facility when the
don't want to depend on Boost.

I've seen that there is already proposal N1381 about this issue, that
dates back to 2002. Does anyone know what happened to it?

The main strenght and main problem in that proposal is that it looks for
a core language change. If the wording had been just a little different,
a library-based approach could have been allowed, and, who knows?, it
might have been considered for TR1. For example, a very lax wording to
achieve this goal could be the following:

----
The header <static_assert> supplies a single macro STATIC_ASSERT(x). The
macro can be used at namespace scope, at class scope or at namespace
scope. The macro expands in an unspecified way, such that unless x is
integral-constant-expression that evaluates to a value different from 0,
then the code is ill-formed [Note: it is intended that if x is an
integral-constant-expression that evaluates to 0, the diagnostic might
hint the user about an expected compile-time condition that hasn't been
statisfied]
----

Now, I guess it's too late for TR1, but I hope this post may stir some
interest for future enhancements.

Alberto

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: jdennett@acm.org (James Dennett)
Date: Sat, 7 May 2005 17:02:36 GMT
Raw View
Alberto Barbati wrote:
> Hi Everybody,
>
> this post has been triggered by Samee Zahur post about error messages,
> but I thought it might deserve a separate thread.
>
> The subject says it all: standardizing a facility like
> BOOST_STATIC_ASSERT. The advantages of a that are apparent: as a tool,
> it has been extensively used, it's simple to implement and a lot of
> programmers seem to be using their own equivalent facility when the
> don't want to depend on Boost.
>
> I've seen that there is already proposal N1381 about this issue, that
> dates back to 2002. Does anyone know what happened to it?
>
> The main strenght and main problem in that proposal is that it looks for
> a core language change. If the wording had been just a little different,
> a library-based approach could have been allowed, and, who knows?, it
> might have been considered for TR1. For example, a very lax wording to
> achieve this goal could be the following:
>
> ----
> The header <static_assert> supplies a single macro STATIC_ASSERT(x). The
> macro can be used at namespace scope, at class scope or at namespace
> scope. The macro expands in an unspecified way, such that unless x is
> integral-constant-expression that evaluates to a value different from 0,
> then the code is ill-formed [Note: it is intended that if x is an
> integral-constant-expression that evaluates to 0, the diagnostic might
> hint the user about an expected compile-time condition that hasn't been
> statisfied]
> ----
>
> Now, I guess it's too late for TR1, but I hope this post may stir some
> interest for future enhancements.

Quoting Pete Becker from another thread yesterday:

tslettebo@hotmail.com wrote:

 >
 > There exists a proposal for something similar to this, called
 > "static_assert"
 > (http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1604.html),
 > and from what I understand, it will likely be added to the "working
 > paper" ("draft standard") for C++0x, so some facility for this will
 > likely end up in the next version of the standard.
 >

It was approved at the last meeting, and is part of the
not-yet-available latest version of the working draft.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: technews@kangaroologic.com ("Jonathan Turkanis")
Date: Mon, 9 May 2005 17:34:23 GMT
Raw View
Alberto Barbati wrote:

> The subject says it all: standardizing a facility like
> BOOST_STATIC_ASSERT.

> I've seen that there is already proposal N1381 about this issue, that
> dates back to 2002. Does anyone know what happened to it?

[From the Boost developers list]

Beman Dawes wrote:
> static_assert was voted into the language by the full committee last
> month in Lillehammer.
>
> --Beman

Jonathan



---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]