On Wed, Jan 29, 2020 at 12:55 AM Gavin Lambert via Boost
On 29/01/2020 18:39, Glen Fernandes wrote:
Basically, a unique_ptr result from an allocate_unique
(a, n) _has_ to store the n somewhere in the unique_ptr because it needs to know how many objects to destroy and what size storage to deallocate. I also provide access for you to get that n. (I just forgot to put it in the documentation).
Does it also implicitly decay to a T*?
Why would it decay to a T*? It's a pointer-like type, for which operator* and operator-> give you the right thing. It doesn't decay to T* nor does it decay to A::pointer (which may not even be T*, i.e. it could be a fancy pointer).
(I did have a look at> https://github.com/boostorg/smart_ptr/blob/master/include/boost/smart_ptr/al... but I don't see any `operator T*`, which is what I'd expect.)
You shouldn't expect that. For any unique_ptr
If not, that seems like it'd make it hard to pass to something expecting a raw pointer (eg. as method argument, or to construct a std::span).
For any given generic unique_ptr