<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">
      code{white-space: pre-wrap;}
      span.smallcaps{font-variant: small-caps;}
      span.underline{text-decoration: underline;}
      div.column{display: inline-block; vertical-align: top; width: 50%;}
  </style>
</head>
<body>
<p>Hi Hugo,</p>
<p>I took the liberty of joining your two messages into one, for the curious this email is in-reply to:</p>
<ul>
<li>https://mailman.videolan.org/pipermail/vlc-devel/2018-July/120262.html</li>
<li>https://mailman.videolan.org/pipermail/vlc-devel/2018-July/120261.html</li>
</ul>
<p>On 2018-07-13 10:12, Hugo Beauzée-Luyssen wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> That's my current plan, new file, new namespace for C++ helpers!
 Although the issue here is that having this function non-static or in
 a non-anonymous namespace will trigger a warning if -Wnoexcept-type is
 enabled (which it is when using -Wall) so maybe this functions will be
 in an anonymous namespace? Or we can disable the warning specifically,
 which I believe would be safe since we only care about our C ABI
 (AFAIK)</code></pre>
</blockquote>
<p>Just put the named namespace within an anonymous namespace, internal linkage, and in a namespace; best of both worlds.</p>
<pre><code> namespace { namespace hugos_awesome_things { ... } }</code></pre>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> So if I understand correctly, the correct noexcept expression would
 be something along the line of

 noexcept( std::is_reference<T>::value == false ||
 std::is_lvalue_reference<decltype(Releaser)>::value == true )</code></pre>
</blockquote>
<p>You can simply mark the function as <code>noexcept</code>, that’s it. If there is an exception from constructing the <code>std::unique_ptr</code> all bets are off anyhow (as that exception from within the <code>noexcept</code> marked <em>unique_ptr</em> constructors causes <em>undefined-behavior</em>).</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> And probably a static_assert should be added to warrant that in case
 of a non-ref type, copy/move ctors is non-throwing?</code></pre>
</blockquote>
<p>Yes, you could add a <code>static_assert</code> to prevent what has been described, but I think it is enough to simple document the fact that a <code>std::unique_ptr</code> will be created with the parameters passed.</p>
<p>By the way, Personally I would implement the two overloads involving <code>&free</code> by using the custom ones; less typing!</p>
<p>Best Regards,<br />
Mr. Lazy</p>
</body>
</html>