2011-02-02 2 views
0

Je suis en train de créer une mémoire partagée avec interprocessus et j'ai une erreur de compilationcarte d'erreur shared_memory stimuler

le code où réside le problème est:

typedef bip::basic_string< char,std::char_traits<char>, 
bip::allocator<char,bip::managed_mapped_file::segment_manager> > shared_string; 

typedef  shared_string MappedType; 
typedef  shared_string MappedType; 
typedef  const int KeyType; 

typedef std::pair<const int, shared_string> ValueType; 

//Alias a map of ints that uses the previous STL-like allocator. 
//Note that the third parameter argument is the ordering function 
//of the map, just like with std::map, used to compare the keys. 
typedef bip::map<KeyType, MappedType, std::less<KeyType>, ShmemAllocator> MyMap; 

mymap = 
      seg->find_or_construct<MyMap>("MyMap")  //object name 
      (std::less<int>() //first constructor parameter 
      ,*alloc_inst); 

et je rencontre des problèmes pour créer la carte. L'erreur est:

c:\GQSDevEnv\3rdParty\boost\boost_1_36_0\boost\interprocess\containers\map.hpp(437) : error C2535: 'std::pair<_Ty1,_Ty2> boost::interprocess::map<Key,T,Pred,Alloc>::insert(const boost::interprocess::map<Key,T,Pred,Alloc>::value_type &)' : member function already defined or declared 
     with 
     [ 
      _Ty1=boost::interprocess::detail::rbtree<const Testing::KeyType,std::pair<const int,Testing::shared_string>,boost::interprocess::detail::select1st<std::pair<const int,Testing::shared_string>>,std::less<const Testing::KeyType>,Testing::ShmemAllocator>::iterator, 
      _Ty2=bool, 
      Key=const Testing::KeyType, 
      T=Testing::MappedType, 
      Pred=std::less<const Testing::KeyType>, 
      Alloc=Testing::ShmemAllocator 
     ] 

Dois-je déclarer différemment? Je travaillais quand je mettais dans std :: apparier un typename d'un modèle, mais maintenant je veux essayer de mettre seulement int ... Je ne sais pas pourquoi cette erreur ...

Merci à adavnce

Répondre

0

Depuis que vous utilisez boost pourquoi ne pas utiliser boost shared_memory_object?

+0

parce que je voulais seulement modifier un modèle qui travaillait avec ce code ... Je pense que je devrais définir quelque chose d'autre. mais je ne sais pas ce qui est: (... – david

+0

Voir ici: http://www.boost.org/doc/libs/1_45_0/doc/html/interprocess/customizing_interprocess.html#interprocess.customizing_interprocess.custom_allocators. le code essaie de faire quelque chose de similaire. – yasouser

Questions connexes