Boost logo

Boost Users :

Subject: [Boost-users] [interprocess] Shared memory compile problem
From: Po-Chun (u901815_at_[hidden])
Date: 2009-04-20 22:30:50


I am a new user and try to write some codes with shared memory using
boost.interprocess.
Basically, I followed the examples and the allocation seems fine. But
the use of shared-memory container gave me a bunch of error messages
related to
"instantiated from here." during compile. The error seems related to
the template.
But I have no idea how to fix it yet. Any suggestion would be helpful.
Thanks.

Po-Chun

My code:
struct LongIntLess
  {
    bool operator()(const uint64_t a, const uint64_t b)
    {
      return a < b;
    }
  };
main () {
using namespace boost::interprocess;
try{
  shared_memory_object::remove("SharedMemory");
  managed_shared_memory segment (create_only, "SharedMemory", sizeof
(uint64_t)*200);

  typedef allocator< uint64_t,
                      managed_shared_memory::segment_manager>
shmAllocator_t;

  typedef set<uint64_t, shmAllocator_t> shrSet_t;

  const shmAllocator_t alloc_inst (segment.get_segment_manager());
  shrSet_t *WrSet_1;
  WrSet_1 = segment.construct<shrSet_t> ("shrSet_t") ("LongIntLess",
alloc_inst); // <= not sure about this
                                                                                                          //
Is it right way to construct a set ?
  WrSet_1->insert(2); // <====== This line causes the error
  } catch (...){
    shared_memory_object::remove("SharedMemory");
    throw();
  }
  shared_memory_object::remove("SharedMemory");
}

The error messages are from these files:
boost/interprocess/containers/
detail/tree.hpp:
boost/intrusive/detail/tree_algorithms.hpp
boost/intrusive/rbtree.hpp
boost/interprocess/containers/detail/tree.hpp
boost/interprocess/containers/set.hpp

One of the error messges is like:

tree.hpp:331: instantiated from 'bool
boost::interprocess::detail::rbtree<Key, Value, KeyOfValue,
KeyCompare, A>::key_node_compare<KeyValueCompare>::operator()(const
KeyType&, const typename
boost::interprocess::detail::node_alloc_holder<A, typename
boost::interprocess::detail::intrusive_rbtree_type<A,
boost::interprocess::detail::value_compare_impl<Key, Value,
KeyCompare, KeyOfValue> >::type>::Node&) const [with KeyType = long
unsigned int, KeyValueCompare =
boost::interprocess::detail::value_compare_impl<long unsigned int,
long unsigned int, boost::interprocess::allocator<long unsigned int,
boost::interprocess::segment_manager<char,
boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family,
boost::interprocess::offset_ptr<void>, 0ul>,
boost::interprocess::iset_index> >,
boost::interprocess::detail::identity<long unsigned int> >, Key = long
unsigned int, Value = long unsigned int, KeyOfValue =
boost::interprocess::detail::identity<long unsigned int>, KeyCompare =
boost::interprocess::allocator<long unsigned int,
boost::interprocess::segment_manager<char,
boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family,
boost::interprocess::offset_ptr<void>, 0ul>,
boost::interprocess::iset_index> >, A = std::allocator<long unsigned
int>]'


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net