Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2007-09-12 12:44:17


Author: johnmaddock
Date: 2007-09-12 12:44:16 EDT (Wed, 12 Sep 2007)
New Revision: 39219
URL: http://svn.boost.org/trac/boost/changeset/39219

Log:
Fixed is_base_of/is_base_and_derived so that you get a compiler error if you try and use them with an incomplete class type.
Text files modified:
   trunk/boost/type_traits/is_base_and_derived.hpp | 8 ++++++++
   1 files changed, 8 insertions(+), 0 deletions(-)

Modified: trunk/boost/type_traits/is_base_and_derived.hpp
==============================================================================
--- trunk/boost/type_traits/is_base_and_derived.hpp (original)
+++ trunk/boost/type_traits/is_base_and_derived.hpp 2007-09-12 12:44:16 EDT (Wed, 12 Sep 2007)
@@ -15,6 +15,7 @@
 #include <boost/type_traits/detail/ice_and.hpp>
 #include <boost/type_traits/remove_cv.hpp>
 #include <boost/config.hpp>
+#include <boost/static_assert.hpp>
 
 // should be the last #include
 #include <boost/type_traits/detail/bool_trait_def.hpp>
@@ -128,6 +129,13 @@
 template<typename B, typename D>
 struct is_base_and_derived_impl2
 {
+ //
+ // May silently do the wrong thing with incomplete types
+ // unless we trap them here:
+ //
+ BOOST_STATIC_ASSERT(sizeof(B));
+ BOOST_STATIC_ASSERT(sizeof(D));
+
     struct Host
     {
 #if !BOOST_WORKAROUND(BOOST_MSVC, == 1310)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk