boostorg / container

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

Alignment ignored in resource_adaptor? #107

Closed vinniefalco closed 5 years ago

vinniefalco commented 5 years ago

resource_adaptor rebinds the caller's Allocator type to char, which destroys the alignment information. Then in allocate it ignores the alignment parameter. Is this the right thing to do?

igaztanaga commented 5 years ago

You are right. operator new is guaranteed to be aligned to any type without extended alignment attributes, but the char-rebound Allocator type could only guarantee byte alignment. I'll review design alternatives to guarantee aligned allocations.

vinniefalco commented 5 years ago

I'm not really happy with the polymorphic allocator / memory resource design but that's not Boost.Container's problem. How do you implement a reference-counted memory resource? Seems there's no way.

I had to roll my own as you can see here: https://github.com/vinniefalco/BeastLounge/blob/develop/include/boost/beast/_experimental/json/storage.hpp#L34

igaztanaga commented 5 years ago

memory_resource isn't thought for that use case, many would not like to pay for a reference-counted design that they won't use ;-)

igaztanaga commented 5 years ago

Thanks for the bug report!