Re: [boost] [review results] hash functions accepted

In-Reply-To: <d1mq8d$b5q$1@sea.gmane.org> nesotto@cs.auc.dk (Thorsten Ottosen) wrote (abridged):
7. the hash_ptr<> suggestion is better done with general indirected function
Did I miss where this was discussed? To recap, we were talking about adding something like: template<typename T> struct hash_ptr { size_t operator()(const T *p) const { return hash_value( *p ); } }; template<typename T> struct equal_ptr { bool operator()( const T *a, const T *b ) const { return *a == *b; } }; to the hash library for use as, eg: unordered_set< MyType *, hash_ptr<MyType>, equal_ptr<MyType> > What do you mean by using a "general indirected function" instead? -- Dave Harris, Nottingham, UK

"Dave Harris" <brangdon@cix.compulink.co.uk> wrote in message news:memo.764802@cix.compulink.co.uk... | In-Reply-To: <d1mq8d$b5q$1@sea.gmane.org> | nesotto@cs.auc.dk (Thorsten Ottosen) wrote (abridged): | > 7. the hash_ptr<> suggestion is better done with general indirected | > function | | Did I miss where this was discussed? No, I don't think so. I'm bringing it up now, because I think the proposed hash_ptr and equal_ptr is a bad idea. | To recap, we were talking about | adding something like: | | template<typename T> | struct hash_ptr { | size_t operator()(const T *p) const { | return hash_value( *p ); | } | }; | | template<typename T> | struct equal_ptr { | bool operator()( const T *a, const T *b ) const { | return *a == *b; | } | }; | | to the hash library for use as, eg: | | unordered_set< MyType *, hash_ptr<MyType>, equal_ptr<MyType> > | | What do you mean by using a "general indirected function" instead? There is a small utility in the Pointer Container library which is more general that hash_ptr ect. You can simply say unordered_set< MyType*, indirect_fun< boost::hash<MyType> >, indirect_fun< std::equal<MyType> > > set; for the rare cases where the index is a pointer. -Thorsten
participants (2)
-
brangdon@cix.compulink.co.uk
-
Thorsten Ottosen