c++ - multi_index template compiling error -


2 questions:
1. need pass parameter modify/modify_key via member?
2. why have compilation error

to see entire code error, can @ http://coliru.stacked-crooked.com/a/d6241361318e1925

the error

multiindex4.h: in member function 'uint32_t crmultiparametermultiindex::modifykeyby(searchingkey&, modifykeytype&) [with searchingtagtype = imei_tag, modifyingtagtype = imei_tag, searchingkey = uint32_t, modifykeytype = uint32_t]': multiindex4.h:183:   instantiated here multiindex4.h:119: error: no matching function call 'boost::multi_index::multi_index_container<userskey, userskey_indices, std::allocator<userskey> >::modify_key(boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<userskey, std::allocator<userskey> > > >&, boost::function<void ()(uint32_t&)>&)' *** errors occurred during build *** 

i have class crmultiparametermultiindex hold multi-index have 2 indexes.

i tried create template function search according part of key , modify part of key.

this class have helper function

template <typename tagtype,typename searchingkey> typename globalhash::index<tagtype>::type::iterator getiteratorby(searchingkey & key){     return  m_pglobalhash->get<tagtype>().find(key) ; } 

and modify function use

template <typename searchingtagtype,typename modifyingtagtype,typename searchingkey,typename modifykeytype> uint32_t modifykeyby(searchingkey & key,modifykeytype & pi_modifykey)     {     uint32_t hres = 1;      //search entry tagtype     typedef  typename globalhash::index<searchingtagtype>::type     indextype;     typename indextype::iterator =  getiteratorby<searchingtagtype>(key);      //entry found     if( != m_pglobalhash->get<searchingtagtype>().end() )     {         //set parameter modify         hres = setparameterkeys<modifyingtagtype>(pi_modifykey);          if(hres == 1)         {             //get iteraror modify             typedef  typename globalhash::index<modifyingtagtype>::type     modifyindextype;             typename modifyindextype::iterator ittomodify =  m_pglobalhash->get<modifyingtagtype>().iterator_to(*it);              boost::function<void( modifykeytype &)> f = boost::bind(&crmultiparametermultiindex::modifykey<modifyingtagtype, modifykeytype >, this, _1);              //modify key failed             if(m_pglobalhash->modify_key(ittomodify , f)==false)                 hres = 0;         }     }     //entry not found     else         hres = 0;     return hres; } 

this compile

uint64_t nfromimsi = 1; uint64_t ntoimsi = 1; m_multiparam.modifykeyby<imsi_tag,imsi_tag>( nfromimsi,ntoimsi) 

but not

uint32_t nfromimsi = 1; uint32_t ntoimsi = 1; m_multiparam.modifykeyby<imei_tag,imei_tag>( nfromimsi,ntoimsi) 

why? , how can compile

and here modifiers

template <> inline void crmultiparametermultiindex::modifykey<imei_tag>( uint32_t & po_key){po_key = m_parameterkeys.imei;} template <> inline void crmultiparametermultiindex::modifykey<imsi_tag>(uint64_t & po_key){po_key = m_parameterkeys.imsi;} 

david,

the problem with

if(m_pglobalhash->modify_key(ittomodify , f)==false) 

lies in fact m_pglobalhashis view index #0 (order_by_imsi) , not accept iterators view #1 (order_by_imei). can either project iterators or select appropriate index:

if(m_pglobalhash->get<modifyingtagtype>().modify_key(ittomodify , f)==false) 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -