There are two ways to do this, depending on what you have at the moment.
If you have an lvalue expression, say the value field in node, you can use std :: addressof like this:
allocator_traits<allocator_type>::construct(alloc, std::addressof(ptr->value), ...);
where ptr is allocator_type::pointer .
However, if you do not have a dereferencing field and want to convert allocator_type::pointer to T* , you need to do the trick first:
template <class T> inline T* to_raw_pointer(T* p) noexcept { return p; } template <class Pointer> inline typename std::pointer_traits<Pointer>::element_type* to_raw_pointer(Pointer p) noexcept { return p != nullptr ? ::to_raw_pointer(p.operator->()) : nullptr; }
And now you can say:
allocator_traits<allocator_type>::construct(alloc, to_raw_pointer(ptr), ...);
source share