Boost logo

Boost :

From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2003-05-21 03:21:12

This little program doesn't work:

#include <boost/type_traits.hpp>

struct Poly { virtual int foo() = 0; };

int main()
[alnsn_at_sat-pc test]$ icc -I $BOOST_ROOT is_polymorphic.cpp
/usr/local/src/boost/boost/type_traits/is_polymorphic.hpp(39): error: return
type is not identical to nor covariant with return type "int" of overridden
virtual function function "Poly::foo"
        virtual void foo();
          detected during:
            instantiation of class
"boost::detail::is_polymorphic_imp1<T>::d2 [with T=Poly]" at line 44
            instantiation of class "boost::detail::is_polymorphic_imp1<T>
[with T=Poly]" at line 79
            instantiation of class "boost::detail::is_polymorphic_imp<T>
[with T=Poly]" at line 84
            instantiation of class "boost::is_polymorphic<T> [with T=Poly]"
at line 7 of "is_polymorphic.cpp"

compilation aborted for is_polymorphic.cpp (code 2)

It has a simple workaround though. Virtual function foo should have unique
signature. One argument of unique type is enough:

// File boost/type_traits/is_polymorphic.hpp
// ...

template <class T>
struct is_polymorphic_imp1

  // ...

   struct d2 : public ncvT
      virtual ~d2()throw();
# ifndef BOOST_MSVC
      // for some reason this messes up VC++ when T has virtual bases:
      struct unique {};
      virtual void foo(unique);
# endif
      char padding[256];

  // ...


Alexander Nasonov
Remove minus and all between minus and at from my e-mail for timely response

Boost list run by bdawes at, gregod at, cpdaniel at, john at