|
Boost Users : |
From: damny_at_[hidden]
Date: 2007-12-28 03:30:10
hi joaquín,
now it works. thank you.
> > are there possibilities to avoid the 'std::string' for the 'name'
> > key?
>
> I'm not getting this question. Could you please elaborate?
i would like to know if it is possible to use char[] or char* as an alphanumeric key value and not std::string.
improper tests didn't work.
daniel
> ----- Mensaje original -----
> De: damny_at_[hidden]
> Fecha: Martes, Diciembre 25, 2007 5:17 pm
> Asunto: [Boost-users] [multi_index] passing 'cons t TYPE' as 'this'
> argument discards qualifiers
> Para: boost-users_at_[hidden]
>
> > merry xmas everyone,
>
> Merry Xmas :)
>
> [...]
> > class cClass {
> > private:
> > int att1;
> > public:
> > std::string nme; // name
> > int idf; // identifier
> > cClass();
> > cClass(std::string nme, int idf);
> > int get_attribute();
> > };
> >
> [...]
> > mMapByNme::iterator itrNme = locMsg.get<0>().find("name1");
> > mMapByIdf::iterator itrIdf = locMsg.get<1>().find(456);
> > printf( "att1 = %d\n", itrNme->get_attribute() );
> [...]
> > main.cpp: In function `int main()':
> > main.cpp:33: error: passing 'const cClass' as 'this' argument of
> > 'int cClass::get_attribute()' discards qualifiers
> > Process terminated with status 1 (0 minutes, 20 seconds)
> >
> > any hints how to solve the problem?
>
> The problem here is that elements of a multi_index_container
> are immutable, and the iterators ony grant const access
> to them. In this regard, the behavior is the same as that
> of a regular std::set. To solve your particular problem you can
> const-qualify the offending member function:
>
> int get_attribute() const;
>
> > how to encapsulate this special multi_index into a class, that
> > fits the above description of the needed 'map'.
>
> You should probably consider whether Boost.Bimap could
> be a better approach, but I see you're already discussing
> this issue with Matías.
>
> > are there possibilities to avoid the 'std::string' for the 'name'
> > key?
>
> I'm not getting this question. Could you please elaborate?
>
> > where are the more easier examples for C++-templates/boost
> > newbies like me :o) ?
>
> HTH,
>
> Joaquín M López Muñoz
> Telefónica, Investiación y Desarrollo
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
__________________________________________________________________________
Erweitern Sie FreeMail zu einem noch leistungsstärkeren E-Mail-Postfach!
Mehr Infos unter http://produkte.web.de/club/?mc=021131
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net