Skip to content

Commit 78bc78a

Browse files
committed
c++20:add a compat. wrapper for std::allocator
problem: C++20 removes deprecated entries from the allocator interface. The boost::multi_index_container relies on some of these members until 1.67.0, one version higher than ships on TOSS4. solution: add a custom allocator that adds the removed fields on top of a std::allocator, and use that with boost::multi_index_container.
1 parent 8becb9f commit 78bc78a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

resource/planner/c++/planner_multi.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ struct planner_multi_meta {
3535
struct idx {};
3636
struct res_type {};
3737

38+
template<typename T>
39+
struct polyfill_allocator : std::allocator<T> {
40+
using std::allocator<T>::allocator;
41+
template<typename U>
42+
struct rebind {
43+
using other = polyfill_allocator<U>;
44+
};
45+
using pointer = T*;
46+
using const_pointer = T const*;
47+
using reference = T&;
48+
using const_reference = T const&;
49+
};
50+
3851
using boost::multi_index_container;
3952
using namespace boost::multi_index;
4053
typedef multi_index_container<
@@ -47,7 +60,8 @@ typedef multi_index_container<
4760
tag<res_type>, // index nametag
4861
member<planner_multi_meta, std::string, &planner_multi_meta::resource_type> // index's key
4962
>
50-
>
63+
>,
64+
polyfill_allocator<planner_multi_meta>
5165
> multi_container;
5266

5367
class planner_multi {

0 commit comments

Comments
 (0)