Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-06-27 15:51:16


On 6/27/19 6:46 PM, Zach Laine via Boost wrote:
> On Wed, Jun 26, 2019, 11:12 PM JeanHeyd Meneide via Boost <
> boost_at_[hidden]> wrote:
>
>> using bop = boost::out_ptr;
>>
>> std::unique_ptr<Numf, DoFree> upNumf;
>> int ret = posix_memalign(bop::out_ptr<void*>(upNumf), 64, nNumf);
>> if (ret != 0) {
>> throw std::runtime_error("something went wrong, but at least we're not
>> leaking memory here.");
>> }
>>
>> Casting support is built in to the API: you can go from strongly typed
>> pointers to void**, or other related pointers by passing the type as a
>> template argument.
>
> These seem like they would make good examples for the docs.

Note that in case of posix_memalign you're not leaking memory even
without out_ptr.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk