Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-03-22 07:24:48


"Dave Harris" <brangdon_at_[hidden]> wrote in message
news:memo.764802_at_cix.compulink.co.uk...
| In-Reply-To: <d1mq8d$b5q$1_at_[hidden]>
| nesotto_at_[hidden] (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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk