From: Gavin Lambert (boost_at_[hidden])
Date: 2020-01-29 11:53:48
At 19:02 29/01/2020, Glen Fernandes wrote:
>You shouldn't expect that. For any unique_ptr<T, D> you can only
>expect that .get() gives you a D::pointer. For default_delete<T>
>this might be T*. But it always depends on the Deleter.
That seems like a significantly more annoying interface than
shared_ptr can hold fancy pointers too, but it happens explicitly
via using fancy<T> rather than plain T, so the explicit
indirection on usage is obvious too.
Having that be an implementation detail of the deleter changing
the effective "type" of the first template argument (which is what
people think of as the type of the pointer, even if the standard
disagrees) seems quite annoying.
Maybe we should have a type-erased unique ownership pointer as
well. I know the reason why we didn't was to avoid heap
allocation or wasted storage for the common case, but there ought
to be some happy middle ground.
>The correct way to get a raw pointer from any
>potentially-fancy-pointer x is: to_address(x)
>This can be boost::to_address (C++03 or higher), or
>std::to_address (C++20 or higher)
Hmm. This is news to me; I don't think I've read about it
anywhere in conjunction with unique_ptr. Perhaps since it doesn't
actually exist yet (most compilers are still mostly C++17).
appears entirely mute on the topic. (There's a passing reference
to fancy pointers but even that doesn't talk about it.)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk