hi,
i'm a newbie to boost an templates.
but for my interrest i experimentalise with that.
so i created an example like the following:
===============================================================================================
template
class tCanMap {
protected:
mutable MAP _mpMap; // map
mutable SC1 *_scNme; // sorting criteria name ... have to init from derived class
public:
tCanMap ();
MAP &getmap () const;
UINT32 setmapelm (ELM val);
const ELM *getmapelm (STRING stNme) const;
};
template
tCanMap
mClass00;
typedef mClass00::nth_index<0>::type mClass00ByNme;
typedef mClass00ByNme::iterator mClass00ByNmeItr;
===============================================================================================
cClass01 : public tCanMap {
STRING nme;
cClass01() { this->_scNme = &(this->_mpMap.get<0>()); }
STRING getnme() { return this->nme; }
}
typedef boost::multi_index_container <
cClass01,
boost::multi_index::indexed_by <
boost::multi_index::hashed_unique < BOOST_MULTI_INDEX_CONST_MEM_FUN(cClass01,STRING,getnme) >
mClass01;
typedef mClass01::nth_index<0>::type mClass01ByNme;
typedef mClass01ByNme::iterator mClass01ByNmeItr;
===============================================================================================
cClass02 : public tCanMap {
cClass02() { this->_scNme = &(this->_mpMap.get<0>()); }
...
}
===============================================================================================
int main (void) {
cClass02 *ptClass02 = new cClass02();
ptClass02->fill_maps_with_elements();
ptClass02->getmapelm("cClass01_Element")->dosomething(); // this works
ptClass02->getmapelm("cClass01_Element")->getmapelm("cClass00_Element")->dosomething(); // seg vault !!!
...
}
===============================================================================================
could you explain why the second try of using "getmapelm" results in an error?
is there a better way to use a template class like above for handle a multi_index list as a member
in similarly classes, whose objects should describe a hierarchical structure?
(note: list shall have multiple indizes :o)
i use boost 1.34.1 and gcc 3.4.5 (mingw special).
many thanx
daniel
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066