From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2020-01-29 05:26:40
> Yes quite. i.e. What you believe is not true about boost::allocate_unique.
> i.e. For auto p = boost::allocate_unique<T>(a, n);
> assert(p.get().size() == n);
> This is because the unique_ptr stores a pointer adaptor around the
> Allocator::pointer which also stores the size.
> So the pointer and size are stored together in the unique_ptr result.
Note, that the size is only stored for allocate_unique<T>(a,n) but
not for allocate_unique<T[N]>(a) since there the N is known at compile
For auto p = allocate_unique<T[N]>(a); your p.get().size() will
return N, but there's no need to store a size_t for N, so we don't.
> To get the plain Allocator::pointer out of it you can use p.get().ptr()
> Or, for example, p.release().ptr() for someone who wants to manage
> it themselves.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk