Boost logo

Boost Users :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-04-23 13:34:34


Ovanes Markarian ha escrito:

> On Mon, April 23, 2007 18:27, Joaquín Mª López Muñoz wrote:
> >
> > Hello Ovanes, the issue of using a boost::tuple member as a key for
> > a Boost.MultiIndex index has arisen in the past. Please read the
> > following posts:

[...]

> Thanks for the quick answer. If I correctly understand your answer,
> I will need either to use a custom key extractor, but then I can't make
> lookup by key like int or string, since I am forced to pass the whole
> tuple instance where the key is extracted. Is it true? Other solution
> would be to avoid using tuples...

No, no, if you use a custom key extractor like the tuple_member_extractor
defined in one of the referred posts, you *can* use a string, an int
or whatever the type of the tuple key member for doing lookup operations.
This is what key extractors (predefine or custom) are for.

> One more question, which might be offtopic. In my other scenario I
> use boost::hash to hash for string member of a pair, but the find fails if
> I pass a string const& and works if I pass const char*.

[...]

I don't know what the problem is but it looks like there's more to it
than you described. Please see the attached compilable snippet mimicking
your scenario: it works OK for GCC 3.2, and it uses the string const&
version of create_type(). Do you observe otherwise? When you say that
the former fails: do you mean you get a compiler error? If so, what's
it like?

> Many thanks and
>
> With Kind Regards,
>
> Ovanes Markarian

Joaquín M López Muñoz
Telefónica, Investigacion y Desarrollo




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