Guest User

Boostcode

a guest
May 28th, 2015
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <boost/interprocess/mapped_region.hpp>
  3. #include <boost/interprocess/managed_shared_memory.hpp>
  4. #include <boost/interprocess/managed_windows_shared_memory.hpp>
  5. #include <boost/interprocess/allocators/allocator.hpp>
  6. #include <boost/interprocess/containers/map.hpp>
  7.  
  8.  
  9. using namespace boost::interprocess;
  10.  
  11. typedef void* mem_managed_type; // GLE_GLOBAL is just void *, but changing it to int doesn't work
  12. struct global_ptr_state; // This is just a POD struct, the definition doesn't matter
  13.  
  14. //typedef managed_shared_memory mem_manager_t;
  15. typedef managed_windows_shared_memory mem_manager_t;
  16. typedef std::pair<const mem_managed_type, global_ptr_state> global_state_pair;
  17. typedef mem_manager_t::segment_manager segm_t;
  18. typedef allocator< global_state_pair, segm_t > my_global_allocator;
  19. typedef std::less<mem_managed_type> mem_managed_type_less;
  20. typedef mem_manager_t::segment_manager segm_manager;
  21. typedef map<const mem_managed_type, global_ptr_state, mem_managed_type_less, my_global_allocator> global_ptr_pair_map;
  22.  
  23. int _tmain(int argc, _TCHAR* argv[])
  24. {
  25.     segm_manager *_segm_manager;
  26.     my_global_allocator *_allocatr;
  27.     global_ptr_pair_map *global_map;
  28.     mem_manager_t managed_pool;
  29.  
  30.     managed_pool = mem_manager_t(create_only, "thisdoesntmatter", 65536, (void *)0x3C000000);
  31.     shared_memory_object _stator_share(open_only, "thisdoesntmattereither", read_write);
  32.     mapped_region _stator_region(_stator_share, read_write, 0, 0, (void *)GLE_STATOR_ADDR);
  33.     _segm_manager = managed_pool.get_segment_manager();
  34.     _allocatr = new my_global_allocator(_segm_manager);
  35.  
  36.     // This line throws the error
  37.     global_map = new global_ptr_pair_map; // This line causes the error
  38. }
Advertisement
Add Comment
Please, Sign In to add comment