On Wed, Feb 14, 2018 at 11:06 PM, Brook Milligan
On Feb 14, 2018, at 2:18 PM, Miguel Ojeda via Boost
wrote: If you have the time, please take a look (specially to the Rationale) and let me know your comments. The code itself is very short and straightforward.
A quick look suggests that this is useful.
Thanks as well for the very quick review!
However, why not have the unique_val class _be_ the RAII class? Couldn't this be done with extra template arguments (or just one) giving construction/destruction policies? You have perfect forwarding so constructor arguments can be forwarded to the policy. Would this not give you the Foo class for free? Just wondering.
I thought about that as a possible extension, but since I typically need/want to write other things (operations, logging...) in the RAII class, I wrote that way. Also, for beginners, it may be easier to understand the ctor/dtor pair than playing with policies. Still, I agree with you, I think adding support for a custom deleter and the like is a good idea (as unique_ptr does) and allows for both styles -- I have it there as a possible extension at the end of Notes. Please let me know if I misunderstood you, though! Cheers, Miguel
Cheers, Brook