[Ace-users] ACE_Stong_Bound_Ptr problem with derived classes

antred NutJob at gmx.net
Fri Jul 6 09:47:52 CDT 2007


Hi all,


I'm using a relatively old ACE version (5.2.1) so I don't know if this
has been fixed in the meantime but at least in this version, the
ACE_Stong_Bound_Ptr template has what I consider a serious deficiency.
Picture the following setup:

    class base {];
    class derived : public base {};

    // assigning a derived object to base class pointer ... this works
just fine; no problems here
    ACE_Stong_Bound_Ptr< base, ACE_Null_Mutex > pBase( new derived );

    // define a function that takes a pointer to base
    void test( ACE_Stong_Bound_Ptr< base, ACE_Null_Mutex > p )
    {
        // ...
    }

    // try to call test(), passing a pointer to derived
    ACE_Stong_Bound_Ptr< derived, ACE_Null_Mutex > pDerived( new
derived );

    // This fails on Visual C++ 2005 ... conversion not possible
    test( pDerived );


Without this functionality (which for instance, boost::shared_ptr
provides just fine), the ACE_Stong_Bound_Ptr template is essentially
useless in the context of polymorphic programming.



More information about the Ace-users mailing list