boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
101 stars 113 forks source link

Apply LWG issue 3471 #199

Closed vinniefalco closed 2 years ago

vinniefalco commented 2 years ago

Allocator::allocate must create objects using launder( new(p) byte[n*sizeof(T)] https://cplusplus.github.io/LWG/issue3471

Change memory_resource::allocate to:

void* p = do_allocate( bytes, alignment );
return std::launder( new (p) std::byte[ bytes ]);

On the build configurations that need it (C++17?) with suitable ifdefs.

pdimov commented 2 years ago

Looks like the right one to use is actually return ::operator new(size, do_allocate(size, align));

igaztanaga commented 2 years ago

I must confess I don't understand yet what launder does. Were concerns raised in P0532r0 addressed?

Do we have some kind of BOOST_LAUNDER (calling some kind of "__builtin_launder", I guess) macro that avoids including , which in many cases includes type_traits and other non-trivial dependencies for such a low-level feature?

vinniefalco commented 2 years ago

Well Peter's comment suggests you don't need launder