Boost logo

Boost Users :

Subject: [Boost-users] shared_ptr failure with undefined type (msvc)
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2011-02-15 12:35:00


Hi,

I came to expect shared_ptr to handle undefined type, but here I got a test case
(simplified from my use case) where it's actually breaks under msvc and works
under gcc:

#include "boost/shared_ptr.hpp"

class UndefinedType;

//// base class for template
class FooBase{
public:
    virtual ~FooBase();
     
    virtual void fff();
};
 
template <typename T>
class Foo: public FooBase {
public:
    virtual void fff()
    {
        // any virtual implementations seen are [have to be able to be]
instantiated. This fails unless T is visible.
        x.reset(x.get());
    }

private:
    boost::shared_ptr<T> x;
};
 
  
//// now use Foo as a field in a class
class User {
    Foo<UndefinedType> y;
};

It fails with:

...\boost-1.39\boost/checked_delete.hpp(32) : error C2027: use of undefined type
'UndefinedType'

Is this expected to compile? Is this MSVC issue?

Gennadiy


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net