
Even though I'm surely not the first one that came up to this, I've got a feature suggestion for the Static Assert library. It would probably be nice to have a variation of the macro that has a second argument with a short description of the problem that caused the assertion. For example: ... #elif defined(BOOST_MSVC) #define BOOST_STATIC_ASSERT2( B, explanation ) \ typedef ::boost::static_assert_test<\ sizeof(::boost::BOOST_JOIN(STATIC_ASSERTION_FAILURE__, explanation)< (bool)( B ) >)>\ BOOST_JOIN(boost_static_assert_typedef_, __COUNTER__) ... static_assert(2 > 3, two_not_larger_than_three); error C2039: 'STATIC_ASSERTION_FAILURE__two_not_larger_than_three' : is not a member of 'boost' Comments? P.S. With the usage of __VA_ARGS__, an implementation that would allow, with some programmer's discipline, both forms merged together might be done!

Oh, crap, my implementation doesn't really work, but, I would like to know whether this idea is any good (to spend more time thinking on it)? :| Sorry.

Goran Mitrovic <gmit@inet.hr> writes:
Oh, crap, my implementation doesn't really work, but, I would like to know whether this idea is any good (to spend more time thinking on it)? :| Sorry.
And it invokes undefined behavior by using double underscores. I suggest looking at some of the MPL diagnostic utilities, such as BOOST_MPL_ASSERT_MSG (http://www.boost.org/libs/mpl/doc/refmanual/assert-msg.html) -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Goran Mitrovic