$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Oleg Fedtchenko (BoostOleg_at_[hidden])
Date: 2004-10-05 13:31:16
To Peter Dimov
Hi, Peter
Could you, please, tell if is there a smart pointer template to a class data-member.
I failed to find  an appropriate pointer among five ones existing in the boost.
I need it for the two tasks appended.
By this time, I have written an extension to intrusive_ptr to meet these needs. If you or anyone else  are interested I could post it or send in person.
Oleg
boostoleg_at_[hidden]
Task 1)
 
class A
{
public:
    A(){ m_wData = 0;}
    WORD* GetData(){ return &m_wData}	
    A* CreateA( int nOffset){ return new A;}	
protected:
    WORD m_wData;
};
main()
{
    A aInstance;	
    WORD* pData = aInstance.CreateA( 15)->GetData();
    *pData = 57; // access violation
}
        
Task 2)
class DocActiveX
{
protected:
    Tree* m_pTree;
public:
    ~DocActiveX(){ if(m_pTree) delete m_pTree;}
    bool Load( const char* lpszPath);    	
    Tree* Parse(){ return m_pTree;}    	
};
class DocDirect
{
protected:
    Tree* m_pTree;
public:
    ~DocDirect(){ if(m_pTree) delete m_pTree;}
    bool Load( const char* lpszPath);    	
    Tree* Parse(){ return m_pTree;}    	
};
class ShowExternal
{
public:
    bool Show( const Tree* pTree);    	
};
class SomeClass
{
protected:
    Tree* m_pTree;
};
void SomeClass::OnLoad()
{
    DocActiveX* pInstance = new DocActiveX;	
    aInstance.Load( lpszSomePath);	
    m_pTree = aInstance.Parse();
}
void SomeClass::OnShow()
{
    ShowExternal ashow;
    ashow.Show( m_pTree);
}