diff --git a/include/loki/TypeManip.h b/include/loki/TypeManip.h index 84fc50b..9fc6ef2 100644 --- a/include/loki/TypeManip.h +++ b/include/loki/TypeManip.h @@ -174,8 +174,34 @@ struct SuperSubclass enum { value = (::Loki::Conversion::exists && !::Loki::Conversion::sameType) }; - // Dummy data member to make sure that both classes are fully defined. - char dummy[sizeof (T) + sizeof (U)]; + // Dummy enum to make sure that both classes are fully defined. + enum{ dontUseWithIncompleteTypes = ( sizeof (T) == sizeof (U) ) }; +}; + +template <> +struct SuperSubclass +{ + enum { value = false }; +}; + +template +struct SuperSubclass +{ + enum { value = (::Loki::Conversion::exists && + !::Loki::Conversion::sameType) }; + + // Dummy enum to make sure that both classes are fully defined. + enum{ dontUseWithIncompleteTypes = ( 0 == sizeof (U) ) }; +}; + +template +struct SuperSubclass +{ + enum { value = (::Loki::Conversion::exists && + !::Loki::Conversion::sameType) }; + + // Dummy enum to make sure that both classes are fully defined. + enum{ dontUseWithIncompleteTypes = ( sizeof (T) == 0 ) }; }; //////////////////////////////////////////////////////////////////////////////// @@ -193,10 +219,39 @@ struct SuperSubclassStrict !::Loki::Conversion::sameType && !::Loki::Conversion::sameType) }; - // Dummy data member to make sure that both classes are fully defined. - char dummy[sizeof (T) + sizeof (U)]; + // Dummy enum to make sure that both classes are fully defined. + enum{ dontUseWithIncompleteTypes = ( sizeof (T) == sizeof (U) ) }; }; +template<> +struct SuperSubclassStrict +{ + enum { value = false }; +}; + +template +struct SuperSubclassStrict +{ + enum { value = (::Loki::Conversion::exists && + !::Loki::Conversion::sameType && + !::Loki::Conversion::sameType) }; + + // Dummy enum to make sure that both classes are fully defined. + enum{ dontUseWithIncompleteTypes = ( 0 == sizeof (U) ) }; +}; + +template +struct SuperSubclassStrict +{ + enum { value = (::Loki::Conversion::exists && + !::Loki::Conversion::sameType && + !::Loki::Conversion::sameType) }; + + // Dummy enum to make sure that both classes are fully defined. + enum{ dontUseWithIncompleteTypes = ( sizeof (T) == 0 ) }; +}; + + } // namespace Loki //////////////////////////////////////////////////////////////////////////////// @@ -238,7 +293,7 @@ struct SuperSubclassStrict // macros are deprecated. // Added extra parenthesis in sizeof in Conversion, to disambiguate function // call from function declaration. T.S. -// July 27, 2005 : compiler error on using Sub/Super with incomplete types +// July 27, 2005 : compiler error on using SuperSubclass/Strict with incomplete types // (credit due to Mark Stevans) ////////////////////////////////////////////////////////////////////////////////