I have an existing variable, e.g.
int a = 3;
How can I now create a boost::shared_ptr to a? For example:
You cannot create a boost::shared_ptr for an existing variable. Items stored in a boost::shared_ptr are stored at creation.
You can however make a boost::shared_ptr that is a copy of an existing variable.
For example
int a = 3; // Existing variable
boost::shared_ptr aCopy = boost::make_shared(a); //Create copy with value of a
Note that you will need to include for make_shared.