[multi_index] passing 'const TYPE' as 'this' argument discards qualifiers
merry xmas everyone, and maybe santa claus or anyone of you have a helping surprise for me :o) after became acquainted with boost and boost.python i have to learn boost.multi_index now. the goal is to build a 'map' with two individual keys (a name and an identifier) per value (object of user class); nme1-idf1-valu1, nme2-idf2-valu2, nme3-idf3-valu3, ... any value should be 'directly' accessible by name or by identifier; valu1:=map[nme1], valu1:=map[idf1]. although i don't understand the documentation perfectly and i'm not familiar with templates i recognise that boost.multi_index is the perfect way :o) and i did the following: //--- cclass.hpp ----------- #ifndef _CCLASS_HPP_ #define _CCLASS_HPP_ class cClass { private: int att1; public: std::string nme; // name int idf; // identifier cClass(); cClass(std::string nme, int idf); int get_attribute(); }; typedef boost::multi_index_container < cClass, boost::multi_index::indexed_by < boost::multi_index::hashed_unique < BOOST_MULTI_INDEX_MEMBER(cMessage,std::string,nme) >, boost::multi_index::ordered_unique < BOOST_MULTI_INDEX_MEMBER(cMessage,int, idf) >
mMap;
typedef mMap::nth_index<0>::type mMapByNme;
typedef mMap::nth_index<1>::type mMapByIdf;
#endif
//--- cclass.cpp -----------
#include
On Dec 25, 2007 1:16 PM,
merry xmas everyone,
and maybe santa claus or anyone of you have a helping surprise for me :o)
after became acquainted with boost and boost.python i have to learn boost.multi_index now. the goal is to build a 'map' with two individual keys (a name and an identifier) per value (object of user class); nme1-idf1-valu1, nme2-idf2-valu2, nme3-idf3-valu3, ... any value should be 'directly' accessible by name or by identifier; valu1:=map[nme1], valu1:=map[idf1]. although i don't understand the documentation perfectly and i'm not familiar with templates i recognise that boost.multi_index is the perfect way :o) and i did the following:
<snip> Code And Problem </snip>
how to encapsulate this special multi_index into a class, that fits the above description of the needed 'map'. are there possibilities to avoid the 'std::string' for the 'name' key? where are the more easier examples for C++-templates/boost newbies like me :o) ?
You can definitely use Boost.MultiIndex to solve your problem. The
thing is that a bidirectional map (a map where you can search in both
ends) is a very common data structure, so a new library called
Boost.Bimap was build on top of Boost.MultiIndex to give you a nicer
interface that plays nicely with standard maps.
In the most simple form you will use it like:
#include
participants (2)
-
damny@web.de
-
Matias Capeletto