
Hi All, I have been in trouble for a day solving this seemingly simple problem - constructing shared_ptr<X> from const X& without copying the X object. The programming logic does not allow me to construct the shared_ptr like this: SX x = SX( new X( x ) ); Consider the following piece of code: void foo( const X& x ) { typedef shared_ptr<X> SX; SX px = SX( &x ); bar( px ); } The compiler gives the following error: In shared_ptr.hpp at line 184: 'initializing' cannot convert from 'const X *' to 'X*'. Please suggest any procedure to solve this problem. -- View this message in context: http://old.nabble.com/Constructing-a-shared-pointer-from-a-const-pointer-tp2... Sent from the Boost - Users mailing list archive at Nabble.com.