|
Boost Users : |
From: JOAQUIN M. LOPEZ MUÑOZ (joaquin_at_[hidden])
Date: 2008-07-13 15:57:25
________________________________________
De: boost-users-bounces_at_[hidden] [boost-users-bounces_at_[hidden]] En nombre de Igor R [boost.lists_at_[hidden]]
Enviado el: domingo, 13 de julio de 2008 21:29
Para: boost-users_at_[hidden]
Asunto: Re: [Boost-users] [boost-users][multi-index] hashed identity: lookup by hash value
[...]
> What's not working is the second approach - with the hash_value
> template function as a the extractor of an additional key (it's not
> compiling).
It's weird, cause it ought to work. For instance, the following does it
nicely both in GCC 3.4.4 and MSVC++ 8.0:
#include <boost/multi_index/global_fun.hpp>
#include <cstddef>
#include <iostream>
struct Element{};
template<typename T>
std::size_t my_hash_value(const T&){return 0;}
namespace mi=boost::multi_index;
typedef mi::global_fun<const Element&,std::size_t,&my_hash_value > key_extractor;
int main()
{
key_extractor k;
Element e;
std::cout<<k(e)<<std::endl;
}
What error messages are you getting? You can make your compiler's life
easier by being a little more explicit when passing my_hash_value (though it's
not obligatory to do so):
typedef mi::global_fun<const Element&,std::size_t,&my_hash_value<Element> > key_extractor;
If you provide me with a little more info about the errors you're getting maybe
I can be more helpful.
Joaquín M López Muñoz
Telefónica, Investigación 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