|
Boost Users : |
From: Boris (boriss_at_[hidden])
Date: 2007-03-14 09:58:12
As I find myself replacing all kind of C++ standard containers with
multi_index_container (a really very useful container) I've been defining
key extractors quite a lot and wonder if there is any shortcut like using
lambda expressions or function objects. Here's some pseudo-code to explain
what I mean:
struct foo
{
std::string s;
foo(std::string s) : s(s) { }
};
typedef multi_index_container<
foo,
indexed_by<
hashed_unique<
boost::bind<std::size_t, &std::string::size, member<foo, std::string,
&foo::s> >
>
>
> mi_t;
The idea is to call another function on the object which is returned by
the key extractor member. Here in this example the multi_index_container
would only store strings with a unique size. However I'm lost how to
define the key extractor. The difficulty is probably that I normally don't
need to specify types when I use boost::bind or lambda expressions. Now I
need to figure out how to use them with multi_index_container - is there
any trick or I better go on defining key extractors?
Boris
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