
Hi All! I am using a third party library where I enqueue a series of events. Each of these events allows the passing of a user context void*. I am attempting to pass the address of a boost::shared_ptr as my context. typedef boost::shared_ptr<CBuffer> CBufferPtr; for (i = 0; i < PREQUEUESIZE; i++) { handle = RegisterBuffer(buffer->m_pBCAMBuffer, m_AOISize); QueueBuffer( handle, &buffer ); // The second parameter is a void* user context data } In the above code "buffer" is my shared_ptr. Later, in my event handler I have the following: CBufferPtr buffer = static_cast<CBufferPtr>(result.Context()); This does not compile due to the following error in VS2005: 1>c:\boost\include\boost-1_33_1\boost\shared_ptr.hpp(125) : error C2440: 'initializing' : cannot convert from 'const void *' to 'CBuffer *' 1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast 1> d:\sourcecode\test.cpp(1572) : see reference to function template instantiation 'boost::shared_ptr<T>::shared_ptr<const void>(Y *)' being compiled 1> with 1> [ 1> T=CBuffer, 1> Y=const void 1> ] The problem seems to be that the third party library call to result.Context() is returing a const void*. It also seems to me that my handler code is actually executing the overloaded operator=, and can never actually cast from a void* to a shared_ptr<T>. What can I do to successfully cast a void* to a shared_ptr<T>? Thanks, Dave