From a5ffec2cd66ebe411e41be9d0ca88b2b2c1fd36a Mon Sep 17 00:00:00 2001 From: joaquintides Date: Sat, 27 Jun 2026 11:49:25 +0200 Subject: [PATCH 1/6] added memory relocatability test --- test/Jamfile.v2 | 5 ++- test/test_all_main.cpp | 4 +- test/test_mmap.cpp | 86 +++++++++++++++++++++++++++++++++++++++++ test/test_mmap.hpp | 11 ++++++ test/test_mmap_main.cpp | 19 +++++++++ 5 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 test/test_mmap.cpp create mode 100644 test/test_mmap.hpp create mode 100644 test/test_mmap_main.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d639fda55..f01979a51 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -53,7 +53,7 @@ test-suite "multi_index" : [ run test_copy_assignment.cpp test_copy_assignment_main.cpp ] [ run test_hash_ops.cpp test_hash_ops_main.cpp ] [ run test_iterators.cpp test_iterators_main.cpp - /boost/foreach//boost_foreach ] + /boost/foreach//boost_foreach ] [ run test_key.cpp test_key_main.cpp : : : [ check-target-builds boost_multi_index_key_supported @@ -61,6 +61,9 @@ test-suite "multi_index" : : : no ] ] [ run test_key_extractors.cpp test_key_extractors_main.cpp ] [ run test_list_ops.cpp test_list_ops_main.cpp ] + [ run test_mmap.cpp test_mmap_main.cpp + /boost/interprocess//boost_interprocess + /boost/uuid//boost_uuid ] [ run test_modifiers.cpp test_modifiers_main.cpp ] [ run test_mpl_ops.cpp test_mpl_ops_main.cpp ] [ run test_node_handling.cpp test_node_handling_main.cpp ] diff --git a/test/test_all_main.cpp b/test/test_all_main.cpp index 41146a36e..85ace1729 100644 --- a/test/test_all_main.cpp +++ b/test/test_all_main.cpp @@ -1,6 +1,6 @@ /* Boost.MultiIndex test suite. * - * Copyright 2003-2020 Joaquin M Lopez Munoz. + * Copyright 2003-2026 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -21,6 +21,7 @@ #include "test_key.hpp" #include "test_key_extractors.hpp" #include "test_list_ops.hpp" +#include "test_mmap.hpp" #include "test_modifiers.hpp" #include "test_mpl_ops.hpp" #include "test_node_handling.hpp" @@ -49,6 +50,7 @@ int main() test_key(); test_key_extractors(); test_list_ops(); + test_mmap(); test_modifiers(); test_mpl_ops(); test_node_handling(); diff --git a/test/test_mmap.cpp b/test/test_mmap.cpp new file mode 100644 index 000000000..319f12c38 --- /dev/null +++ b/test/test_mmap.cpp @@ -0,0 +1,86 @@ +/* Boost.MultiIndex test for memory relocatability. + * + * Copyright 2003-2026 Joaquin M Lopez Munoz. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * See http://www.boost.org/libs/multi_index for library home page. + */ + +#include "test_mmap.hpp" + +#include /* keep it first to prevent nasty warns in MSVC */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void test_mmap() +{ + using namespace boost::multi_index; + namespace bip=boost::interprocess; + using container=multi_index_container< + int, + indexed_by< + ordered_unique>, + hashed_unique>, + ranked_unique>, + sequenced<>, + random_access<> + >, + bip::allocator + >; + using iterator0=nth_index::type::iterator; + using iterator1=nth_index::type::iterator; + using iterator2=nth_index::type::iterator; + using iterator3=nth_index::type::iterator; + using iterator4=nth_index::type::iterator; + constexpr auto container_name="container"; + + static auto file_name_str= + std::string("./test_mmap_")+ + to_string(boost::uuids::random_generator()()); + static auto file_name=file_name_str.c_str(); + + bip::file_mapping::remove(file_name); + auto pseg1=std::make_unique( + bip::create_only,file_name,65536); + container& c1=*pseg1->construct(container_name)( + container::ctor_args_list(), + container::allocator_type(pseg1->get_segment_manager())); + for(int i=0;i<100;++i)c1.insert(i); + auto v0=**pseg1->construct("it0")(c1.get<0>().begin()); + auto v1=**pseg1->construct("it1")(c1.get<1>().begin()); + auto v2=**pseg1->construct("it2")(c1.get<2>().begin()); + auto v3=**pseg1->construct("it3")(c1.get<3>().begin()); + auto v4=**pseg1->construct("it4")(c1.get<4>().begin()); + + bip::managed_mapped_file seg2(bip::open_only,file_name); + pseg1=nullptr; + container& c2=*seg2.find(container_name).first; + auto it0=*seg2.find("it0").first; + auto it1=*seg2.find("it1").first; + auto it2=*seg2.find("it2").first; + auto it3=*seg2.find("it3").first; + auto it4=*seg2.find("it4").first; + BOOST_TEST_EQ(*it0,v0); + BOOST_TEST_EQ(std::distance(it0,c2.get<0>().end()),c2.size()); + BOOST_TEST_EQ(*it1,v1); + BOOST_TEST_EQ(std::distance(it1,c2.get<1>().end()),c2.size()); + BOOST_TEST_EQ(*it2,v2); + BOOST_TEST_EQ(std::distance(it2,c2.get<2>().end()),c2.size()); + BOOST_TEST_EQ(*it3,v3); + BOOST_TEST_EQ(std::distance(it3,c2.get<3>().end()),c2.size()); + BOOST_TEST_EQ(*it4,v4); + BOOST_TEST_EQ(std::distance(it4,c2.get<4>().end()),c2.size()); +} diff --git a/test/test_mmap.hpp b/test/test_mmap.hpp new file mode 100644 index 000000000..b4ce963f8 --- /dev/null +++ b/test/test_mmap.hpp @@ -0,0 +1,11 @@ +/* Boost.MultiIndex test for memory relocatability. + * + * Copyright 2003-2026 Joaquin M Lopez Munoz. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * See http://www.boost.org/libs/multi_index for library home page. + */ + +void test_mmap(); diff --git a/test/test_mmap_main.cpp b/test/test_mmap_main.cpp new file mode 100644 index 000000000..c53faf6a7 --- /dev/null +++ b/test/test_mmap_main.cpp @@ -0,0 +1,19 @@ +/* Boost.MultiIndex test for memory relocatability. + * + * Copyright 2003-2026 Joaquin M Lopez Munoz. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * See http://www.boost.org/libs/multi_index for library home page. + */ + +#include +#include "test_mmap.hpp" + +int main() +{ + test_mmap(); + return boost::report_errors(); +} + From 4702e15f50ca323c8c7efe31db90861f214d393f Mon Sep 17 00:00:00 2001 From: joaquintides Date: Sat, 27 Jun 2026 11:54:22 +0200 Subject: [PATCH 2/6] added missing #includes --- test/test_mmap.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test_mmap.cpp b/test/test_mmap.cpp index 319f12c38..7b7f19e37 100644 --- a/test/test_mmap.cpp +++ b/test/test_mmap.cpp @@ -24,6 +24,9 @@ #include #include #include +#include +#include +#include void test_mmap() { From b814b7fabd0fb6e142ed5ea2b210bb0a60867c4a Mon Sep 17 00:00:00 2001 From: joaquintides Date: Sat, 27 Jun 2026 12:01:17 +0200 Subject: [PATCH 3/6] avoided C++14 std::make_unique --- test/test_mmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_mmap.cpp b/test/test_mmap.cpp index 7b7f19e37..b72e5b288 100644 --- a/test/test_mmap.cpp +++ b/test/test_mmap.cpp @@ -56,8 +56,8 @@ void test_mmap() static auto file_name=file_name_str.c_str(); bip::file_mapping::remove(file_name); - auto pseg1=std::make_unique( - bip::create_only,file_name,65536); + std::unique_ptr pseg1( + new bip::managed_mapped_file(bip::create_only,file_name,65536)); container& c1=*pseg1->construct(container_name)( container::ctor_args_list(), container::allocator_type(pseg1->get_segment_manager())); From 14afe8a6f912a8c9511c782429794bf4915f36ec Mon Sep 17 00:00:00 2001 From: joaquintides Date: Sat, 27 Jun 2026 12:19:05 +0200 Subject: [PATCH 4/6] added hashed index local iterators to the test --- test/test_mmap.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_mmap.cpp b/test/test_mmap.cpp index b72e5b288..a47e42a2a 100644 --- a/test/test_mmap.cpp +++ b/test/test_mmap.cpp @@ -45,6 +45,7 @@ void test_mmap() >; using iterator0=nth_index::type::iterator; using iterator1=nth_index::type::iterator; + using local_iterator1=nth_index::type::local_iterator; using iterator2=nth_index::type::iterator; using iterator3=nth_index::type::iterator; using iterator4=nth_index::type::iterator; @@ -64,6 +65,7 @@ void test_mmap() for(int i=0;i<100;++i)c1.insert(i); auto v0=**pseg1->construct("it0")(c1.get<0>().begin()); auto v1=**pseg1->construct("it1")(c1.get<1>().begin()); + auto lv1=**pseg1->construct("lit1")(c1.get<1>().begin(0)); auto v2=**pseg1->construct("it2")(c1.get<2>().begin()); auto v3=**pseg1->construct("it3")(c1.get<3>().begin()); auto v4=**pseg1->construct("it4")(c1.get<4>().begin()); @@ -73,6 +75,7 @@ void test_mmap() container& c2=*seg2.find(container_name).first; auto it0=*seg2.find("it0").first; auto it1=*seg2.find("it1").first; + auto lit1=*seg2.find("lit1").first; auto it2=*seg2.find("it2").first; auto it3=*seg2.find("it3").first; auto it4=*seg2.find("it4").first; @@ -80,6 +83,9 @@ void test_mmap() BOOST_TEST_EQ(std::distance(it0,c2.get<0>().end()),c2.size()); BOOST_TEST_EQ(*it1,v1); BOOST_TEST_EQ(std::distance(it1,c2.get<1>().end()),c2.size()); + BOOST_TEST_EQ(*lit1,lv1); + BOOST_TEST_EQ( + std::distance(lit1,c2.get<1>().end(0)),c2.get<1>().bucket_size(0)); BOOST_TEST_EQ(*it2,v2); BOOST_TEST_EQ(std::distance(it2,c2.get<2>().end()),c2.size()); BOOST_TEST_EQ(*it3,v3); From 205afe2577c3841a5c7502538f5d2fcd9b637e77 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Sat, 27 Jun 2026 12:31:14 +0200 Subject: [PATCH 5/6] made all iterators store allocator-provided pointers to the nodes --- .../detail/bidir_node_iterator.hpp | 11 ++++--- .../detail/hash_index_iterator.hpp | 17 +++++----- .../multi_index/detail/hash_index_node.hpp | 17 +++++++--- .../multi_index/detail/ord_index_node.hpp | 25 +++++++++++---- .../multi_index/detail/rnd_index_node.hpp | 31 ++++++++++++------- .../multi_index/detail/rnd_node_iterator.hpp | 11 ++++--- .../multi_index/detail/seq_index_node.hpp | 23 ++++++++++---- 7 files changed, 88 insertions(+), 47 deletions(-) diff --git a/include/boost/multi_index/detail/bidir_node_iterator.hpp b/include/boost/multi_index/detail/bidir_node_iterator.hpp index 5cc49e203..539c76c58 100644 --- a/include/boost/multi_index/detail/bidir_node_iterator.hpp +++ b/include/boost/multi_index/detail/bidir_node_iterator.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2023 Joaquin M Lopez Munoz. +/* Copyright 2003-2026 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -14,6 +14,7 @@ #endif #include /* keep it first to prevent nasty warns in MSVC */ +#include #include #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) @@ -77,7 +78,7 @@ class bidir_node_iterator: template void save(Archive& ar,const unsigned int)const { - node_base_type* bnode=node; + node_base_type* bnode=get_node(); ar<>core::make_nvp("pointer",bnode); - node=static_cast(bnode); + node=typename Node::pointer(static_cast(bnode)); } #endif @@ -94,10 +95,10 @@ class bidir_node_iterator: typedef Node node_type; - Node* get_node()const{return node;} + Node* get_node()const{return raw_ptr(node);} private: - Node* node; + typename Node::pointer node; }; template diff --git a/include/boost/multi_index/detail/hash_index_iterator.hpp b/include/boost/multi_index/detail/hash_index_iterator.hpp index 0bbcbdf90..d3d95ae50 100644 --- a/include/boost/multi_index/detail/hash_index_iterator.hpp +++ b/include/boost/multi_index/detail/hash_index_iterator.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2023 Joaquin M Lopez Munoz. +/* Copyright 2003-2026 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -14,6 +14,7 @@ #endif #include /* keep it first to prevent nasty warns in MSVC */ +#include #include #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) @@ -76,7 +77,7 @@ class hashed_index_iterator: template void save(Archive& ar,const unsigned int)const { - node_base_type* bnode=node; + node_base_type* bnode=get_node(); ar<>core::make_nvp("pointer",bnode); - node=static_cast(bnode); + node=typename Node::pointer(static_cast(bnode)); if(version<1){ BucketArray* throw_away; /* consume unused ptr */ ar>>core::make_nvp("pointer",throw_away); @@ -105,13 +106,13 @@ class hashed_index_iterator: { node_base_type* bnode; ar>>core::make_nvp("pointer",bnode); - node=static_cast(bnode); + node=typename Node::pointer(static_cast(bnode)); if(version<1){ BucketArray* buckets; ar>>core::make_nvp("pointer",buckets); - if(buckets&&node&&node->impl()==buckets->end()->prior()){ + if(buckets&&bnode&&node->impl()==buckets->end()->prior()){ /* end local_iterators used to point to end node, now they are null */ - node=0; + node=typename Node::pointer(0); } } } @@ -121,7 +122,7 @@ class hashed_index_iterator: typedef Node node_type; - Node* get_node()const{return node;} + Node* get_node()const{return raw_ptr(node);} private: @@ -135,7 +136,7 @@ class hashed_index_iterator: Node::template increment_local(node); } - Node* node; + typename Node::pointer node; }; template< diff --git a/include/boost/multi_index/detail/hash_index_node.hpp b/include/boost/multi_index/detail/hash_index_node.hpp index 17bd966d1..e200c6202 100644 --- a/include/boost/multi_index/detail/hash_index_node.hpp +++ b/include/boost/multi_index/detail/hash_index_node.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2025 Joaquin M Lopez Munoz. +/* Copyright 2003-2026 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -712,6 +712,13 @@ struct hashed_index_node: typedef typename trampoline::pointer impl_pointer; typedef typename trampoline::const_pointer const_impl_pointer; typedef typename trampoline::difference_type difference_type; + typedef allocator_rebind_t< + typename trampoline::impl_allocator_type, + hashed_index_node> final_allocator_type; + typedef allocator_pointer_t< + final_allocator_type> pointer; + typedef allocator_const_pointer_t< + final_allocator_type> const_pointer; template struct node_alg{ @@ -754,15 +761,15 @@ struct hashed_index_node: /* interoperability with hashed_index_iterator */ template - static void increment(hashed_index_node*& x) + static void increment(pointer& x) { - x=from_impl(node_alg::type::after(x->impl())); + x=pointer(from_impl(node_alg::type::after(x->impl()))); } template - static void increment_local(hashed_index_node*& x) + static void increment_local(pointer& x) { - x=from_impl(node_alg::type::after_local(x->impl())); + x=pointer(from_impl(node_alg::type::after_local(x->impl()))); } }; diff --git a/include/boost/multi_index/detail/ord_index_node.hpp b/include/boost/multi_index/detail/ord_index_node.hpp index 008e1ea8a..39a0e67ff 100644 --- a/include/boost/multi_index/detail/ord_index_node.hpp +++ b/include/boost/multi_index/detail/ord_index_node.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2025 Joaquin M Lopez Munoz. +/* Copyright 2003-2026 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -131,6 +131,7 @@ struct ordered_index_node_compressed_base { typedef ordered_index_node_traits< AugmentPolicy,Allocator> node_traits; + typedef typename node_traits::allocator node_allocator; typedef ordered_index_node_impl< AugmentPolicy,Allocator>* pointer; typedef const ordered_index_node_impl< @@ -608,6 +609,14 @@ struct ordered_index_node: typedef typename trampoline::const_pointer const_impl_pointer; typedef typename trampoline::difference_type difference_type; typedef typename trampoline::size_type size_type; + typedef allocator_rebind_t< + typename trampoline::node_allocator, + ordered_index_node> final_allocator_type; + typedef allocator_pointer_t< + final_allocator_type> pointer; + typedef allocator_const_pointer_t< + final_allocator_type> const_pointer; + impl_color_ref color(){return trampoline::color();} ordered_index_color color()const{return trampoline::color();} @@ -646,20 +655,24 @@ struct ordered_index_node: raw_ptr(x))); } - /* interoperability with bidir_node_iterator */ + /* Interoperability with bidir_node_iterator and index impl. + * Templated for raw-pointer/non-raw-pointer versions. + */ - static void increment(ordered_index_node*& x) + template + static void increment(NodePtr& x) { impl_pointer xi=x->impl(); trampoline::increment(xi); - x=from_impl(xi); + x=NodePtr(from_impl(xi)); } - static void decrement(ordered_index_node*& x) + template + static void decrement(NodePtr& x) { impl_pointer xi=x->impl(); trampoline::decrement(xi); - x=from_impl(xi); + x=NodePtr(from_impl(xi)); } }; diff --git a/include/boost/multi_index/detail/rnd_index_node.hpp b/include/boost/multi_index/detail/rnd_index_node.hpp index 20a827188..f7ecd98f1 100644 --- a/include/boost/multi_index/detail/rnd_index_node.hpp +++ b/include/boost/multi_index/detail/rnd_index_node.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2025 Joaquin M Lopez Munoz. +/* Copyright 2003-2026 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -215,11 +215,18 @@ struct random_access_index_node: typedef random_access_index_node_trampoline trampoline; public: - typedef typename trampoline::impl_type impl_type; - typedef typename trampoline::pointer impl_pointer; - typedef typename trampoline::const_pointer const_impl_pointer; - typedef typename trampoline::difference_type difference_type; - typedef typename trampoline::ptr_pointer impl_ptr_pointer; + typedef typename trampoline::impl_type impl_type; + typedef typename trampoline::pointer impl_pointer; + typedef typename trampoline::const_pointer const_impl_pointer; + typedef typename trampoline::difference_type difference_type; + typedef typename trampoline::ptr_pointer impl_ptr_pointer; + typedef allocator_rebind_t< + typename trampoline::node_allocator, + random_access_index_node> final_allocator_type; + typedef allocator_pointer_t< + final_allocator_type> pointer; + typedef allocator_const_pointer_t< + final_allocator_type> const_pointer; impl_ptr_pointer& up(){return trampoline::up();} impl_ptr_pointer up()const{return trampoline::up();} @@ -254,25 +261,25 @@ struct random_access_index_node: /* interoperability with rnd_node_iterator */ - static void increment(random_access_index_node*& x) + static void increment(pointer& x) { impl_pointer xi=x->impl(); trampoline::increment(xi); - x=from_impl(xi); + x=pointer(from_impl(xi)); } - static void decrement(random_access_index_node*& x) + static void decrement(pointer& x) { impl_pointer xi=x->impl(); trampoline::decrement(xi); - x=from_impl(xi); + x=pointer(from_impl(xi)); } - static void advance(random_access_index_node*& x,difference_type n) + static void advance(pointer& x,difference_type n) { impl_pointer xi=x->impl(); trampoline::advance(xi,n); - x=from_impl(xi); + x=pointer(from_impl(xi)); } static difference_type distance( diff --git a/include/boost/multi_index/detail/rnd_node_iterator.hpp b/include/boost/multi_index/detail/rnd_node_iterator.hpp index 7149cb0f2..af3875cb1 100644 --- a/include/boost/multi_index/detail/rnd_node_iterator.hpp +++ b/include/boost/multi_index/detail/rnd_node_iterator.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2023 Joaquin M Lopez Munoz. +/* Copyright 2003-2026 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -14,6 +14,7 @@ #endif #include /* keep it first to prevent nasty warns in MSVC */ +#include #include #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) @@ -87,7 +88,7 @@ class rnd_node_iterator: template void save(Archive& ar,const unsigned int)const { - node_base_type* bnode=node; + node_base_type* bnode=get_node(); ar<>core::make_nvp("pointer",bnode); - node=static_cast(bnode); + node=typename Node::pointer(static_cast(bnode)); } #endif @@ -104,10 +105,10 @@ class rnd_node_iterator: typedef Node node_type; - Node* get_node()const{return node;} + Node* get_node()const{return raw_ptr(node);} private: - Node* node; + typename Node::pointer node; }; template diff --git a/include/boost/multi_index/detail/seq_index_node.hpp b/include/boost/multi_index/detail/seq_index_node.hpp index c6e568b1c..97508a301 100644 --- a/include/boost/multi_index/detail/seq_index_node.hpp +++ b/include/boost/multi_index/detail/seq_index_node.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2025 Joaquin M Lopez Munoz. +/* Copyright 2003-2026 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -158,6 +158,13 @@ struct sequenced_index_node:Super,sequenced_index_node_trampoline typedef typename trampoline::pointer impl_pointer; typedef typename trampoline::const_pointer const_impl_pointer; typedef typename trampoline::difference_type difference_type; + typedef allocator_rebind_t< + typename trampoline::node_allocator, + sequenced_index_node> final_allocator_type; + typedef allocator_pointer_t< + final_allocator_type> pointer; + typedef allocator_const_pointer_t< + final_allocator_type> const_pointer; impl_pointer& prior(){return trampoline::prior();} impl_pointer prior()const{return trampoline::prior();} @@ -192,20 +199,24 @@ struct sequenced_index_node:Super,sequenced_index_node_trampoline raw_ptr(x))); } - /* interoperability with bidir_node_iterator */ + /* Interoperability with bidir_node_iterator and index impl. + * Templated for raw-pointer/non-raw-pointer versions. + */ - static void increment(sequenced_index_node*& x) + template + static void increment(NodePtr& x) { impl_pointer xi=x->impl(); trampoline::increment(xi); - x=from_impl(xi); + x=NodePtr(from_impl(xi)); } - static void decrement(sequenced_index_node*& x) + template + static void decrement(NodePtr& x) { impl_pointer xi=x->impl(); trampoline::decrement(xi); - x=from_impl(xi); + x=NodePtr(from_impl(xi)); } }; From e6e9c53f0a19dc892de4c40609e188d8942a0ac6 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Sat, 27 Jun 2026 18:51:01 +0200 Subject: [PATCH 6/6] updated docs --- doc/reference/multi_index_container.html | 7 +++++-- doc/release_notes.html | 7 ++++++- doc/tutorial/creation.html | 6 +++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/reference/multi_index_container.html b/doc/reference/multi_index_container.html index 8d250e2fc..66685691e 100644 --- a/doc/reference/multi_index_container.html +++ b/doc/reference/multi_index_container.html @@ -552,8 +552,11 @@

Instantiation types

p shall dereference to *p. + multi_index_containers and all their iterators do not store references + to allocated elements other than through the allocator's pointer type. + Indices of a given multi_index_container instantiation cannot have duplicate tags, either within a single index or in two different indices. @@ -1069,9 +1072,9 @@

Serialization


-

Revised October 25th 2025

+

Revised June 27th 2026

-

© Copyright 2003-2025 Joaquín M López Muñoz. +

© Copyright 2003-2026 Joaquín M López Muñoz. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/doc/release_notes.html b/doc/release_notes.html index ef0a33080..52a4aeda5 100644 --- a/doc/release_notes.html +++ b/doc/release_notes.html @@ -78,6 +78,11 @@

Boost 1.92 release

    +
  • Fancy pointer support has been extended so that multi_index_container + iterators now store references to the elements through the allocator's pointer type. + In particular, this means that iterators can now be placed in shared memory using + Boost.Interprocess allocators. +
  • Fixed a performance issue with hashed indices when rehashing at very large container sizes (PR#94). Contributed by Daniel Král. @@ -858,7 +863,7 @@

    Boost 1.33 release


    -

    Revised April 24th 2026

    +

    Revised June 27th 2026

    © Copyright 2003-2026 Joaquín M López Muñoz. Distributed under the Boost Software diff --git a/doc/tutorial/creation.html b/doc/tutorial/creation.html index 0a0213873..3773bb889 100644 --- a/doc/tutorial/creation.html +++ b/doc/tutorial/creation.html @@ -201,7 +201,7 @@

    Special allocator support

    An important type of non-standard allocators supported are those provided by the Boost Interprocess Library; this opens up the possibility of placing multi_index_containers -in shared memory. +and their iterators in shared memory.

    @@ -340,9 +340,9 @@ 

    Serialization


    -

    Revised July 17th 2007

    +

    Revised June 27th 2026

    -

    © Copyright 2003-2007 Joaquín M López Muñoz. +

    © Copyright 2003-2026 Joaquín M López Muñoz. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at