Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does P::************ mean in Boost assert.hpp file?

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++?

like image 548
stoneyan Avatar asked Nov 19 '14 20:11

stoneyan


Video Answer


1 Answers

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*>::************)’ 
like image 140
sbabbi Avatar answered Oct 02 '22 21:10

sbabbi