Boost logo

Boost Users :

From: Andy Tompkins (atompkins_at_[hidden])
Date: 2004-09-17 13:27:01


Hi,

I am trying to use com smart pointers with boost::mem_fn

I defined the following so that mem_fn would know about _com_ptr_t s:

template <typename Interface>
inline typename _com_ptr_t<Interface>::Interface*
        get_pointer(_com_ptr_t<Interface> const& p)
{
        return p.GetInterfacePtr();
}

but when I use the function object returned from boost::bind, I get a null
pointer in my _com_ptr_t

ADODB::_RecordsetPtr recordSet(__uuidof(ADODB::Recordset));
...
boost::bind(&ADODB::_Recordset::Close, recordSet)();

The problem seems to be in mem_fn_template.hpp

The function

  class BOOST_MEM_FN_NAME(mf0)::operator()(U &u) const

calls
        BOOST_MEM_FN_RETURN call(u, &u);

and _com_ptr_t::operator&() calls _Release() and sets m_pInterface = NULL;

Is there any way to get this to work correctly?

Thanks in advance.
Andy.


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