I wouldn’t use std::bind though, just make a lambda.<br><div class="gmail_quote"><div dir="ltr">On Thu, Feb 22, 2018 at 6:06 PM Pavel Labath via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">labath added a comment.<br>
<br>
In <a href="https://reviews.llvm.org/D43662#1016939" rel="noreferrer" target="_blank">https://reviews.llvm.org/D43662#1016939</a>, @vsk wrote:<br>
<br>
> > What do you think about a syntax like:<br>
> ><br>
> > lldb_utility::CleanUp cleanup_our(::close, our_socket); // The CleanUp constructor creates the std::function internally<br>
><br>
> @labath I find the current version of the code more readable, since the behavior of the cleanup is apparent in less time. And I'd prefer to keep the CleanUp utility very small, without any scope for expansion. I don't think the ergonomics of the new syntax outweigh the advantages of a simpler approach.<br>
<br>
<br>
I don't think this would complicate anything. It should literally be a matter of replacing your constructor with:<br>
<br>
template<typename F, typename... Args><br>
CleanUp(F &&f, Args &&..args)<br>
: PerformCleanup(true), Clean(std::bind(std::forward<F>(f), std::forward<Args>(args)...) {}<br>
<br>
Although I can see how you may find the other usage syntax more understandable, so I am not adamant about this...<br>
<br>
<br>
<a href="https://reviews.llvm.org/D43662" rel="noreferrer" target="_blank">https://reviews.llvm.org/D43662</a><br>
<br>
<br>
<br>
</blockquote></div>