Hello.
I'm trying to use a private node allocator for an unordered_map placed
in the shared memory:
#include
#include
#include
#include
#include
#include <functional>
#include <utility>
int main ()
{
using namespace boost::interprocess;
struct shm_remove
{
shm_remove() { shared_memory_object::remove("MySharedMemory"); }
~shm_remove(){ shared_memory_object::remove("MySharedMemory"); }
} remover;
managed_shared_memory segment
(create_only
,"MySharedMemory" //segment name
,65536); //segment size in bytes
typedef int KeyType;
typedef float MappedType;
typedef std::pair ValueType;
typedef private_node_allocator
ShmemAllocator;
typedef boost::unordered_map MyMap;
ShmemAllocator alloc_inst (segment.get_segment_manager());
MyMap *mymap =
segment.construct<MyMap>("MyMap") //object name
(3,
boost::hash<KeyType>(),
std::equal_to<KeyType>(),
alloc_inst);
for(int i = 0; i < 100; ++i){
mymap->insert(std::pair(i, (float)i));
}
return 0;
}
It gives a compilation error:
/usr/local/include/boost/unordered/detail/unique.hpp:30:43: error: no
type named 'pointer' in
'boost::interprocess::private_node_allocator, boost::interprocess::segment_manager, 0>,
iset_index>, 64>, std::__1::pair >,
boost::interprocess::segment_manager, 0>,
iset_index>, 64>'
A, unique_node >::type::pointer node_pointer;
What am I doing wrong?