In boost/mpl/assert.hpp, I saw something like this:
template<class Pred> struct eval_assert { typedef typename extract_assert_pred<Pred>::type P; typedef typename P::type p_type; typedef typename ::boost::mpl::if_c<p_type::value, AUX778076_ASSERT_ARG(assert<false>), failed ************ P::************ >::type type; };
If the first ************
can be treated as pointers of struct failed, the P::************
really doesn't make any sense to me. Is this standard C++?
The point of this code is to help the compiler produce "visible" error messages.
In pre static_assert
era, compiling a template-heavy code could easily produce ~100 lines of error messages even for a single mistake, and 99% of those lines are often meaningless.
The 10 pointers trick is useful to point out the actual error, for example:
BOOST_STATIC_ASSERT((std::is_same<T,U>));
With T=void*
and U=char*
compiled with gcc produces ~10 error lines, but you can easily see the relevant one:
error: no matching function for call to ‘assertion_failed(mpl_::failed************ std::is_same<void*, char*>::************)’
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With