$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] How to convert shared_ptr to pointer?
From: Chris Cleeland (chris.cleeland_at_[hidden])
Date: 2013-01-03 13:02:02
On Thu, Jan 3, 2013 at 11:27 AM, Igor R <boost.lists_at_[hidden]> wrote:
> > I have shared_ptr<int> variable. I need to pass a int* pointer to a
> function
> > call. How to pass shared_ptr<int> as int *?
>
> shared_ptr<int> p;
> p.get();
>
>
> But make sure the function doesn't store this raw pointer, otherwise
> it would defeat the whole purpose of shared_ptr.
>
More specifically, make sure that you have a shared_ptr<> in scope for the
entire time the raw pointer is in scope. Failure to do so will surely
result in badness at some point.
-- Chris Cleeland