Hi all, I'm looking for a map that has no matter about key types, so I can use such map storing int indexed objects and also, i.e., char indexed objects, as all-in-one container. It can be useful to have such type of key-type unaware containers, as we can find with other languages. What about existing one?
On Mon, Feb 22, 2010 at 3:27 PM, Michele Caini <michele.caini@gmail.com> wrote:
Hi all, I'm looking for a map that has no matter about key types, so I can use such map storing int indexed objects and also, i.e., char indexed objects, as all-in-one container. It can be useful to have such type of key-type unaware containers, as we can find with other languages.
What about existing one?
Not even other languages do that. For example, take Python, you can only use hashable objects as a key, that is the link. As such you can make even the normal STD map accept anything, as long as it is hashable with a proper wrapper.
Il 23/02/2010 19:30, Igor R ha scritto:
I'm looking for a map that has no matter about key types, so I can use such map storing int indexed objects and also, i.e., char indexed objects, as all-in-one container.
Maybe something like std::map<boost::variant<int, char>, std::string> can be helpful? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Mmm... that's good! :-) Thanks a lot, Igor!
Could one use boost::any as a key? 2010/2/23 Michele Caini <michele.caini@gmail.com>
Il 23/02/2010 19:30, Igor R ha scritto:
I'm looking for a map that has no matter about key types, so I can use such map storing int indexed objects and also, i.e., char indexed objects, as all-in-one container.
Maybe something like std::map<boost::variant<int, char>, std::string> can be helpful? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Mmm... that's good! :-) Thanks a lot, Igor! _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Igor R wrote:
Maybe something like std::map<boost::variant<int, char>, std::string> can be helpful?
Igore Dmit. wrote:
Could one use boost::any as a key?
There is no any ordering defined for boost::any objects, so no, it is not possible to use it as Key in ordered associative containers. Gevorg
participants (5)
-
Gevorg Voskanyan
-
Igor R
-
Igore Dmit.
-
Michele Caini
-
OvermindDL1