Hi all,
I see multiset is not present in boost interprocess, so I tried to use a
"set" with a customized comparator to achieve multiset functionality.
sample code:
struct set_comparator
{
bool operator()(const int& a, const int& b) const
{
return a < b; // if change a <= b then seeing an errror
}
};
bip::shared_memory_object::remove("SHM");
bip::managed_shared_memory segment(bip::open_or_create, "SHM",
2047*1024*1024);
typedef bip::allocator
ShmemAllocator;
typedef bip::set ShmemSet;
segment.destroy<ShmemSet>("MySet");
ShmemSet *sample1 = segment.construct<ShmemSet>("MySet")(set_comparator(),
segment.get_segment_manager());
std::cout << "Insert in shared set:" << std::endl;
sample1->insert(40);
std::cout << "Insert in shared set:" << std::endl;
sample1->insert(40); // Crashing here
sample1->insert(40);
sample1->insert(40);
sample1->insert(20);
sample1->insert(20);
sample1->insert(20);
sample1->insert(20);
sample1->insert(20);
when i try duplicate insertion, seeing following error,
/usr/include/boost/intrusive/bstree.hpp:1331:
boost::intrusive::bstree_impl::iterator
boost::intrusive::bstree_impl::insert_unique_commit(boost::intrusive::bstree_impl::reference, const insert_commit_data&) [with ValueTraits =
boost::intrusive::bhtraits,
boost::intrusive::rbtree_node_traits, boost::intrusive::normal_link, boost::intrusive::dft_tag, 3>;
VoidOrKeyOfValue = void; VoidOrKeyComp =
boost::container::value_to_node_compare,
boost::intrusive::tree_value_compare, main()::set_comparator,
boost::move_detail::identity<int>, bool, true>, bool>; SizeType = long
unsigned int; bool ConstantTimeSize = true; boost::intrusive::algo_types
AlgoType = boost::intrusive::RbTreeAlgorithms; HeaderHolder = void;
boost::intrusive::bstree_impl::iterator =
boost::intrusive::tree_iterator,
boost::intrusive::rbtree_node_traits, boost::intrusive::normal_link, boost::intrusive::dft_tag, 3>,
false>; boost::intrusive::bstree_impl::reference = boost::container::dtl::tree_node&; boost::intrusive::bstree_impl::insert_commit_data =
boost::intrusive::insert_commit_data_t
, long int, long unsigned int, 0> >]: Assertion `( p == this->end() ||
!this->comp()(*p, value) )' failed.
"Need input on this or is this expected behaviour as per boost??"
--
Regards,
Murali Kishore