Boost C++ Libraries: Ticket #11045: Boost.Any allocator support RFC https://svn.boost.org/trac10/ticket/11045 <p> Right now it is possible to use Boost.Any with types that require special alignment (sse intrinsics, Eigen3 data types, ...) by overriding the global operators new and delete. This solution is far from optimal, since it results in everything in the whole program being overaligned. </p> <p> I'm opening this Request For Comments to discuss a possibly better solution to this problem. </p> <p> The gist of the idea is for Boost.Any to store a polymorphic allocator (of possibly zero size), such that the user can provide an allocator when initializing/assigning/copying an any object. </p> <p> This increases the API of Boost.Any (changes proposed below). It also decreases its performance, since allocating/deallocating memory would incur an extra virtual function call. It might also increase the size of the any object. One has, however, to consider the impact of the current workarounds in larger programs. Over-aligning all allocations might have a larger impact on performance and memory footprint than the proposed changes. </p> <p> I think the following interface should be enough: </p> <ul><li>any(polymorphic_allocator allocator = default_allocator()); </li></ul><ul><li>any(const any &amp;, polymorphic_allocator allocator = default_allocator()); </li></ul><p> </p> <ul><li>any(any &amp;&amp;, polymorphic_allocator allocator = default_allocator()); </li></ul><ul><li>template&lt;typename <a class="missing wiki">ValueType</a>&gt; any(const <a class="missing wiki">ValueType</a> &amp;, polymorphic_allocator allocator = default_allocator()); </li></ul><ul><li>template&lt;typename <a class="missing wiki">ValueType</a>&gt; any(<a class="missing wiki">ValueType</a> &amp;&amp;, polymorphic_allocator allocator = default_allocator()); </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11045 Trac 1.4.3 Antony Polukhin Sat, 24 Apr 2021 16:03:26 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11045#comment:1 https://svn.boost.org/trac10/ticket/11045#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">obsolete</span> </li> </ul> <p> Moved to github <a class="ext-link" href="https://github.com/boostorg/any/issues/22"><span class="icon">​</span>https://github.com/boostorg/any/issues/22</a> </p> Ticket