Dirk Gerrits wrote: > Jaap Suter wrote: > >> Hi, >> >> In my own meta-programming I tend to use a lot of static_asserts and >> concept >> checks. However, these do have a negative impact on my compile-times. >> Take, >> for example, a meta-function that takes a type-list as its parameter. >> Assume >> a pre-condition is that the list may not be empty. What I can do is: >> >> BOOST_STATIC_ASSERT( (mpl::not_< typename mpl::empty< List >::type >> >>> ::type::value) ); >> >> >> >> And while this is a good thing most of the time, sometimes I would >> like to >> disable these checks so my compiles go faster. What is the recommended >> way >> of doing this? >> >> 1. Using a define: >> >> #ifndef UID_DO_CHECKS >> BOOST_STATIC_ASSERT( (mpl::not_< typename mpl::empty< List >::type >> >>> ::type::value) ); >> >> >> #endif >> >> 2. Using a boolean trait or policy, that is passed to a meta-if >> statement: >> >> BOOST_STATIC_ASSERT( ( >> mpl::apply_if< check_policy, >> mpl::not_< typename mpl::empty< List >::type >::type::value, >> true_ >::type::value )); >> >> 3. Other ideas? > > > I'd say something like: > > #ifdef STATIC_NDEBUG > # define BOOST_STATIC_ASSERT2(e) BOOST_STATIC_ASSERT(e) > #else > # define BOOST_STATIC_ASSERT2(e) (void(e)) > #endif > > Analogous to <cassert>.
Argh, the if and else branches should be reversed of course. You've gotta love negative logic. ;)
Dirk Gerrits
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
