升压进程间flat_map operator []的编译错误 [英] Boost interprocess flat_map operator[] compilation errors
问题描述
我要建一些包装过的boost ::进程间:: flat_map,问题是,我无法用运算符[]
或在
出于某种原因。当我使用找到
或插入
它编译成功地
的typedef的boost ::进程间:: managed_shared_memory :: segment_manager SegmentManager;
TYPEDEF的boost ::进程间::分配器<焦炭,SegmentManager> CharAllocator;
TYPEDEF的boost ::进程间:: basic_string的<焦炭,的std :: char_traits<焦炭>中
CharAllocator> ShmString;
的typedef短关键字类型;
的typedef ShmString MappedType;
的typedef的std ::对<常量短,ShmString>值类型;TYPEDEF的boost ::进程间::分配器<值类型,
提高::进程间:: managed_shared_memory :: segment_manager> ShMemAlloc;
TYPEDEF的boost ::进程间:: flat_map<关键字类型,MappedType,
的std ::以下<短>中ShMemAlloc> ShMap;
类包装{上市: 包装(升压::进程间:: managed_shared_memory * memSeg):
m_memSeg(memSeg){
常量ShMemAlloc initAlloc(m_memSeg-> get_segment_manager());
m_storage = m_memSeg->构建
< ShMap> (::提高::进程间anonymous_instance)
(性病::少<&关键字类型GT;(),initAlloc);
ShmString STR(initAlloc);
值类型VAL(10,STR); m_storage->插入(VAL); //好 ShMap:迭代它= m_storage->找到(5); //好
如果(它= m_storage->!结束())
IT->第二个= str中; (* m_storage)[5] =海峡; //编译错误
};
〜包装();保护:
提高::进程间:: managed_shared_memory * m_memSeg; ShMap * m_storage;
};
这似乎就像有一个与在运算符[]
调用内部分配器类型演绎出了问题,但我不知道如何正确使用它。
下面是错误报告:
../升压/有/升压/集装箱/ string.hpp:在实例'boost::container::container_detail::basic_string_base<Allocator>::members_holder::members_holder() [与分配器=的boost ::进程间::分配器&LT;焦炭,升压::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;]':
../boost/include/boost/container/string.hpp:104:18:;分配器&GT;从'的boost ::容器:: container_detail :: basic_string_base&LT所需:: basic_string_base()与分配器=的boost ::进程间::分配器&LT;焦炭,升压::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;]
../boost/include/boost/container/string.hpp:596:16:从促进容器:: basic_string的:: LT和要求,图表,性状,分配器&GT; :: basic_string的()[带有图表=字符;性状=的std :: char_traits&LT;焦炭取代;分配器=的boost ::进程间::分配器&LT;焦炭,升压::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;]
../boost/include/boost/container/detail/value_init.hpp:31:13:; T&GT; :: value_init()与T =的boost ::容器从的boost ::容器:: container_detail :: value_init&LT需要:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提高::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&GT; ,提高::进程间:: iset_index&GT; &GT; &GT;]
../boost/include/boost/container/flat_map.hpp:846:52:从'的boost ::容器:: flat_map&LT需要;关键,T,比较,分配器&GT; :: mapped_type&安培;提高::容器:: flat_map&LT;关键,T,比较,分配器&GT; :: priv_subscript(常量为key_type&安培;)与主要=短整型; T =的boost ::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提高::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;提升: :进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;取代;比较=的std ::以下&LT;短整型取代;分配器=的boost ::进程间::分配器&LT;的std ::对&LT;常量短整型,提振::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提振:: ::间和segment_manager LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT; &GT; &gt;中的boost ::进程间:: segment_manager&LT;焦炭,升压::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT;取代;提高::容器:: flat_map&LT;关键,T,比较,分配器&GT; :: mapped_type =提振::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,升压: :进程间:: segment_manager&LT;焦炭,升压::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;取代;提高::容器:: flat_map&LT;关键,T,比较,分配器&GT; ::为key_type =短整型]
../boost/include/boost/container/flat_map.hpp:469:4:!从'typename的提升需要:: enable_if_c≤(((::提振&is_class LT; BOOST_MOVE_TEMPL_PARAM&GT; ::值)||(升压:: move_detail :: is_rv&LT; BOOST_MOVE_TEMPL_PARAM&GT; ::值))及及(升压:: is_same&LT;!关键,BOOST_MOVE_TEMPL_PARAM&GT; ::值)),T&安培;&GT; ::类型boost ::容器:: flat_map&LT;关键, T,比较,分配器&GT; ::运算符[](常量BOOST_MOVE_TEMPL_PARAM&安培;)与BOOST_MOVE_TEMPL_PARAM = INT;重点=短整型; T =的boost ::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提高::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;提升: :进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;取代;比较=的std ::以下&LT;短整型取代;分配器=的boost ::进程间::分配器&LT;的std ::对&LT;常量短整型,提振::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提振:: ::间和segment_manager LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT; &GT; &gt;中的boost ::进程间:: segment_manager&LT;焦炭,升压::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT;取代; TYPENAME的boost :: enable_if_c≤(((提高:: is_class&LT;!BOOST_MOVE_TEMPL_PARAM&GT;!::值)||(升压:: move_detail :: is_rv&LT; BOOST_MOVE_TEMPL_PARAM&GT; ::值))及和放大器;!(提高:: is_same&LT ;关键,BOOST_MOVE_TEMPL_PARAM&GT; ::值)),T&安培;&GT; ::类型=提振::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提振:: ::间和segment_manager LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT; &GT;&安培]
./include/.h:240:23:从这里需要
../boost/include/boost/container/string.hpp:218:22:错误:调用'的boost ::进程间::分配器&LT没有匹配功能;焦炭,升压::进程间:: segment_manager&LT;焦炭,升压: :进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT; ::分配器()
../boost/include/boost/container/string.hpp:在实例'boost::container::container_detail::basic_string_base<Allocator>::members_holder::members_holder() [与分配器=的boost ::进程间::分配器&LT;焦炭,升压::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;]':
../boost/include/boost/container/string.hpp:104:18:;分配器&GT;从'的boost ::容器:: container_detail :: basic_string_base&LT所需:: basic_string_base()与分配器=的boost ::进程间::分配器&LT;焦炭,升压::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;]
../boost/include/boost/container/string.hpp:596:16:从促进容器:: basic_string的:: LT和要求,图表,性状,分配器&GT; :: basic_string的()[带有图表=字符;性状=的std :: char_traits&LT;焦炭取代;分配器=的boost ::进程间::分配器&LT;焦炭,升压::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;]
../boost/include/boost/container/detail/value_init.hpp:31:13:; T&GT; :: value_init()与T =的boost ::容器从的boost ::容器:: container_detail :: value_init&LT需要:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提高::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&GT; ,提高::进程间:: iset_index&GT; &GT; &GT;]
../boost/include/boost/container/flat_map.hpp:846:52:从'的boost ::容器:: flat_map&LT需要;关键,T,比较,分配器&GT; :: mapped_type&安培;提高::容器:: flat_map&LT;关键,T,比较,分配器&GT; :: priv_subscript(常量为key_type&安培;)与主要=短整型; T =的boost ::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提高::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;提升: :进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;取代;比较=的std ::以下&LT;短整型取代;分配器=的boost ::进程间::分配器&LT;的std ::对&LT;常量短整型,提振::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提振:: ::间和segment_manager LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT; &GT; &gt;中的boost ::进程间:: segment_manager&LT;焦炭,升压::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT;取代;提高::容器:: flat_map&LT;关键,T,比较,分配器&GT; :: mapped_type =提振::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,升压: :进程间:: segment_manager&LT;焦炭,升压::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;取代;提高::容器:: flat_map&LT;关键,T,比较,分配器&GT; ::为key_type =短整型]
../boost/include/boost/container/flat_map.hpp:469:4:!从'typename的提升需要:: enable_if_c≤(((::提振&is_class LT; BOOST_MOVE_TEMPL_PARAM&GT; ::值)||(升压:: move_detail :: is_rv&LT; BOOST_MOVE_TEMPL_PARAM&GT; ::值))及及(升压:: is_same&LT;!关键,BOOST_MOVE_TEMPL_PARAM&GT; ::值)),T&安培;&GT; ::类型boost ::容器:: flat_map&LT;关键, T,比较,分配器&GT; ::运算符[](常量BOOST_MOVE_TEMPL_PARAM&安培;)与BOOST_MOVE_TEMPL_PARAM = INT;重点=短整型; T =的boost ::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提高::进程间:: segment_manager&LT;焦炭,提高::进程间:: rbtree_best_fit&LT;提升: :进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT;取代;比较=的std ::以下&LT;短整型取代;分配器=的boost ::进程间::分配器&LT;的std ::对&LT;常量短整型,提振::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提振:: ::间和segment_manager LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT; &GT; &gt;中的boost ::进程间:: segment_manager&LT;焦炭,升压::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT;取代; TYPENAME的boost :: enable_if_c≤(((提高:: is_class&LT;!BOOST_MOVE_TEMPL_PARAM&GT;!::值)||(升压:: move_detail :: is_rv&LT; BOOST_MOVE_TEMPL_PARAM&GT; ::值))及和放大器;!(提高:: is_same&LT ;关键,BOOST_MOVE_TEMPL_PARAM&GT; ::值)),T&安培;&GT; ::类型=提振::容器:: basic_string的&LT;焦炭,的std :: char_traits&LT;焦炭&gt;中的boost ::进程间::分配器&LT;焦炭,提振:: ::间和segment_manager LT;焦炭,提高::进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT; &GT;&安培]
./include/.h:240:23:从这里需要
../boost/include/boost/container/string.hpp:218:22:错误:调用'的boost ::进程间::分配器&LT没有匹配功能;焦炭,升压::进程间:: segment_manager&LT;焦炭,升压: :进程间:: rbtree_best_fit&LT;的boost ::进程间:: mutex_family&gt;中的boost ::进程间:: iset_index&GT; &GT; ::分配器()
这花了一些挖掘。你的问题是, flat_map ::运算符[]
要求映射类型 T
是默认施工的,因为如果对象不存在需要能够在该位置插入一个缺省对象
您 ShmString
是的不的默认施工的,因为它没有一个默认施工的分配器(它使用共享内存分配器)。
如此看来,你的情况,你将无法使用运算符[]
并有能力使用其他方法,如插入
,找到
等
I'm building some wrapper over the boost::interprocess::flat_map, the problem is, that i'm unable to use operator[]
or at
for some reason. When i'm using find
or insert
it compiles succesfully.
typedef boost::interprocess::managed_shared_memory::segment_manager SegmentManager;
typedef boost::interprocess::allocator<char, SegmentManager> CharAllocator;
typedef boost::interprocess::basic_string<char, std::char_traits<char>,
CharAllocator> ShmString;
typedef short KeyType;
typedef ShmString MappedType;
typedef std::pair<const short, ShmString> ValueType;
typedef boost::interprocess::allocator<ValueType,
boost::interprocess::managed_shared_memory::segment_manager> ShMemAlloc;
typedef boost::interprocess::flat_map<KeyType, MappedType,
std::less<short>, ShMemAlloc> ShMap;
class Wrapper {
public:
Wrapper(boost::interprocess::managed_shared_memory* memSeg) :
m_memSeg(memSeg) {
const ShMemAlloc initAlloc(m_memSeg->get_segment_manager());
m_storage = m_memSeg->construct
<ShMap> (boost::interprocess::anonymous_instance)
(std::less<KeyType>(), initAlloc);
ShmString str(initAlloc);
ValueType val(10, str);
m_storage->insert(val); //Ok
ShMap::iterator it = m_storage->find(5); //Ok
if(it != m_storage->end())
it->second = str;
(*m_storage)[5] = str; //Compilation error
};
~Wrapper();
protected:
boost::interprocess::managed_shared_memory* m_memSeg;
ShMap* m_storage;
};
It seem's like there is a problem with type deduction in allocator inside the operator[]
call, but i have no idea how to use it correctly.
Here is the error report:
../boost/include/boost/container/string.hpp: In instantiation of 'boost::container::container_detail::basic_string_base<Allocator>::members_holder::members_holder() [with Allocator = boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >]':
../boost/include/boost/container/string.hpp:104:18: required from 'boost::container::container_detail::basic_string_base<Allocator>::basic_string_base() [with Allocator = boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >]'
../boost/include/boost/container/string.hpp:596:16: required from 'boost::container::basic_string<CharT, Traits, Allocator>::basic_string() [with CharT = char; Traits = std::char_traits<char>; Allocator = boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >]'
../boost/include/boost/container/detail/value_init.hpp:31:13: required from 'boost::container::container_detail::value_init<T>::value_init() [with T = boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > >]'
../boost/include/boost/container/flat_map.hpp:846:52: required from 'boost::container::flat_map<Key, T, Compare, Allocator>::mapped_type& boost::container::flat_map<Key, T, Compare, Allocator>::priv_subscript(const key_type&) [with Key = short int; T = boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > >; Compare = std::less<short int>; Allocator = boost::interprocess::allocator<std::pair<const short int, boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > > >, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >; boost::container::flat_map<Key, T, Compare, Allocator>::mapped_type = boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > >; boost::container::flat_map<Key, T, Compare, Allocator>::key_type = short int]'
../boost/include/boost/container/flat_map.hpp:469:4: required from 'typename boost::enable_if_c<(((! boost::is_class<BOOST_MOVE_TEMPL_PARAM>::value) || (! boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>::value)) && (! boost::is_same<Key, BOOST_MOVE_TEMPL_PARAM>::value)), T&>::type boost::container::flat_map<Key, T, Compare, Allocator>::operator[](const BOOST_MOVE_TEMPL_PARAM&) [with BOOST_MOVE_TEMPL_PARAM = int; Key = short int; T = boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > >; Compare = std::less<short int>; Allocator = boost::interprocess::allocator<std::pair<const short int, boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > > >, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >; typename boost::enable_if_c<(((! boost::is_class<BOOST_MOVE_TEMPL_PARAM>::value) || (! boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>::value)) && (! boost::is_same<Key, BOOST_MOVE_TEMPL_PARAM>::value)), T&>::type = boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > >&]'
./include/.h:240:23: required from here
../boost/include/boost/container/string.hpp:218:22: error: no matching function for call to 'boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >::allocator()'
../boost/include/boost/container/string.hpp: In instantiation of 'boost::container::container_detail::basic_string_base<Allocator>::members_holder::members_holder() [with Allocator = boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >]':
../boost/include/boost/container/string.hpp:104:18: required from 'boost::container::container_detail::basic_string_base<Allocator>::basic_string_base() [with Allocator = boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >]'
../boost/include/boost/container/string.hpp:596:16: required from 'boost::container::basic_string<CharT, Traits, Allocator>::basic_string() [with CharT = char; Traits = std::char_traits<char>; Allocator = boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >]'
../boost/include/boost/container/detail/value_init.hpp:31:13: required from 'boost::container::container_detail::value_init<T>::value_init() [with T = boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > >]'
../boost/include/boost/container/flat_map.hpp:846:52: required from 'boost::container::flat_map<Key, T, Compare, Allocator>::mapped_type& boost::container::flat_map<Key, T, Compare, Allocator>::priv_subscript(const key_type&) [with Key = short int; T = boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > >; Compare = std::less<short int>; Allocator = boost::interprocess::allocator<std::pair<const short int, boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > > >, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >; boost::container::flat_map<Key, T, Compare, Allocator>::mapped_type = boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > >; boost::container::flat_map<Key, T, Compare, Allocator>::key_type = short int]'
../boost/include/boost/container/flat_map.hpp:469:4: required from 'typename boost::enable_if_c<(((! boost::is_class<BOOST_MOVE_TEMPL_PARAM>::value) || (! boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>::value)) && (! boost::is_same<Key, BOOST_MOVE_TEMPL_PARAM>::value)), T&>::type boost::container::flat_map<Key, T, Compare, Allocator>::operator[](const BOOST_MOVE_TEMPL_PARAM&) [with BOOST_MOVE_TEMPL_PARAM = int; Key = short int; T = boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > >; Compare = std::less<short int>; Allocator = boost::interprocess::allocator<std::pair<const short int, boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > > >, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >; typename boost::enable_if_c<(((! boost::is_class<BOOST_MOVE_TEMPL_PARAM>::value) || (! boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>::value)) && (! boost::is_same<Key, BOOST_MOVE_TEMPL_PARAM>::value)), T&>::type = boost::container::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> > >&]'
./include/.h:240:23: required from here
../boost/include/boost/container/string.hpp:218:22: error: no matching function for call to 'boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>, boost::interprocess::iset_index> >::allocator()'
This took some digging. Your problem is that flat_map::operator[]
requires the mapped type T
to be default constructable because if the object does not exist it needs to be able to insert a default object at that location.
Your ShmString
is not default constructable because it doesn't have a default constructable allocator (it has to use the shared memory allocator).
Thus it appears that in your case you will be unable to make use of operator[]
and have to use other methods like insert
, find
, etc.
这篇关于升压进程间flat_map operator []的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!