|
Boost Users : |
Subject: [Boost-users] Constructing a shared pointer from a const pointer
From: veerus (veeranjaneyulu.sadhanala_at_[hidden])
Date: 2009-11-11 01:41:17
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-tp26296800p26296800.html Sent from the Boost - Users mailing list archive at Nabble.com.
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