Boost logo

Boost :

From: Johan Råde (rade_at_[hidden])
Date: 2007-09-12 12:03:04


When some type traits, for instance is_base_of,
are called with incomplete types,
then they may silently "return" incorrect results.
It would be better if they failed to compile with incomplete types.

Here is a suggestion how that might be implemented:

   template<int> struct assert_complete0 {};

   template<typename T> struct assert_complete :
     public assert_complete0<sizeof(T)> {};

   template<typename B, typename T> is_base_of :
     public assert_complete<B>, public assert_complete<T> ...

I have tested this with with VC 7.1, and it works.
Will this work on other platforms?
Are there any reasons not to add this check?

Johan Råde
CTO, Qlucore AB


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