What does P::************ mean in Boost assert.hpp file?
Solution 1:
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*>::************)’
Solution 2:
It's a pointer-to-pointer-to-...-member of type P
, where the member is a data member of type pointer-to-pointer-to-...-failed
.
In this case the goal is simply to cause compilation to fail by referring to a member of P
with a very high degree of probability that it won't exist. In C++11 you'd just use static_assert
instead, but of course Boost needs to be portable to pre-C++11 dialects.
Solution 3:
F P::*
is a "pointer to member of P
of type F
".
F P::**
is a "pointer to pointer to member of P
of type F
".
More *
s adds more "pointer to" in front.
In this case, F
is failed ************
, i.e., "pointer to pointer to ... pointer to failed
".