|
Boost Users : |
Subject: Re: [Boost-users] Convert boost::shared_ptr to std::shared_ptr for boost::dll::import
From: Nevin Liber (nevin_at_[hidden])
Date: 2018-04-12 20:20:52
On Thu, Apr 12, 2018 at 2:48 PM, David Demelier via Boost-users <
boost-users_at_[hidden]> wrote:
> Hello,
>
> In my application I use std::shared_ptr in the public API for loading
> plugins. I wanted to use boost::dll to import dynamically plugins as
> well.
>
> It looks like for some reasons that it still use boost::shared_ptr
> instead of std::shared_ptr even though C++11 is 7 years old.
>
> I wanted to convert the boost shared_ptr to std with the following
> function:
>
> std::shared_ptr<plugin> load(boost::shared_ptr<plugin> ptr)
> {
> return std::shared_ptr<plugin>(ptr.get(), [ptr] (auto) {});
> }
>
Look at <
https://stackoverflow.com/questions/12314967/cohabitation-of-boostshared-ptr-and-stdshared-ptr>,
which does a ptr.reset() in the deleter. It also describes the caveats
with this hack.
-- Nevin ":-)" Liber <mailto:nevin_at_[hidden] <nevin_at_[hidden]>> +1-847-691-1404
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