Boost logo

Boost :

From: Jaap Suter (J.Suter_at_[hidden])
Date: 2003-03-09 14:05:30


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?

Thanks,

Jaap Suter

p.s. If this is considered off-topic and more suitable for
comp.lang.c++(.moderated) I apologize. Please let me know.


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