Is this the canonical way to make a static assertion that class D is derived from class B?
Or is there any reason to use static_casts instead?
Neither seems to generate any code, even at no optimisation.
Both give the error message "error: no matching function for call to 'B::B(D&)'" when the assertion fails, and are silent otherwise.
Is there a way, easy or not (I intend to hide this in a macro), to produce a less cryptic error message? (Not that I really really care)
Code:
(B)(*(D*)(0));
Code:
static_cast<B>(*static_cast<D*>(0));
Both give the error message "error: no matching function for call to 'B::B(D&)'" when the assertion fails, and are silent otherwise.
Is there a way, easy or not (I intend to hide this in a macro), to produce a less cryptic error message? (Not that I really really care)
Comment