boostorg / boostorg/any

Boost.Any allocator support RFC

Open
#22 0 comments 0 reactions 0 assignees View on GitHub
enhancement PR welcomed
Dominant language
C++
Stars
37
Forks
60
Avg merge
5d 22h
Merged PRs (30d)
1

Description

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.

I'm opening this Request For Comments to discuss a possibly better solution to this problem.

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.

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.

I think the following interface should be enough:
```
any(polymorphic_allocator allocator = default_allocator());

any(const any &, polymorphic_allocator allocator = default_allocator());

any(any &&, polymorphic_allocator allocator = default_allocator());

template any(const ValueType &, polymorphic_allocator allocator = default_allocator());

template any(ValueType &&, polymorphic_allocator allocator = default_allocator());
```

----
Issue imported from https://svn.boost.org/trac10/ticket/11045
Reported by: gonzalobg88@…

Contributor guide

No contributing guide indexed for this repository

Research direction

The RFC names no source files, tests, or entry points. Start by reviewing the proposed Boost.Any allocator constructors and the stated alignment, performance, and object-size trade-offs; done means an agreed API and implementation direction.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.