[vlc-devel] [PATCH] vlc_common: Add C++ memory management helpers

Filip Roséen filip at atch.se
Fri Jul 13 11:04:36 CEST 2018


On 2018-07-13 10:54, Hugo Beauzée-Luyssen wrote:

> >  You can simply mark the function as `noexcept`, that's it. If there
> >  is an exception from constructing the `std::unique_ptr` all bets are
> >  off anyhow (as that exception from within the `noexcept` marked
> >  *unique_ptr* constructors causes *undefined-behavior*).
> > 
> 
> For the noexcept constructors, sure, but AFAIU constructors taking
> an r-value reference to the deleter are not noexcept

Both of the two possibly called constructors of `std::unique_ptr` are
marked `noexcept`. The one accepting `U const&` requires `U` to have a
*nothrow copy-constructible*, and the one accepting `U&&` requires `U`
to have a *nothrow move-constructible*.

> > By the way, Personally I would implement the two overloads involving
> > `&free` by using the custom ones; less typing!
> > 
> 
> Hm, do you mean having a default param = &free for the releaser?

I simply meant calling one from the other, easier to document and
easier for people to understand - also not too sure if doxygen handles
default *template-arguments* that well (if at all).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20180713/db92f334/attachment.html>


More information about the vlc-devel mailing list