Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-02-20 01:18:47


False alarm - I had the hash function but failed to specify
conditions for its inclustion - thansk again

Robert Ramey

Robert Ramey wrote:
> Very good. That explains it all to me.
>
> Of course any good answer begets another question. The problem only
> occurs with GCC standard library implementation. At first I thought
> that other libraries
> included a default hash function for Free. Now that I think about, I
> don't know for a fact that any other libraries actually implement the
> hash_map and hash_set
> so perhaps its never even been tested.
>
> Thanks again
>
> Robert Ramey
>
>
>
> Daniel Frey wrote:
>> Robert Ramey wrote:
>>> http://tinyurl.com/s4ohn Shows the error message which is provoked
>>> by the following test code:
>>>
>>> // test array of objects
>>> BOOST_STD_EXTENSION_NAMESPACE::hash_set<A> ahash_set;
>>> ...
>>> std::vector<A> tvec, tvec1;
>>> std::copy(ahash_set.begin(), ahash_set.end(),
>>> std::back_inserter(tvec)); // error starts here
>>> std::sort(tvec.begin(), tvec.end());
>>>
>>> a) I can't see anything wrong with this.
>>> b) No other compilers complain
>>> c) I can't follow the error message
>>
>> The error message means that there is no hash-function for A. The
>> following example works for GCC 4.0.3, removing the
>> hash<A>-specialization reveals the error you found:
>>
>> #include <vector>
>> #include <ext/hash_set>
>>
>> class A {};
>>
>> namespace __gnu_cxx
>> {
>> template<> struct hash<A>
>> {
>> size_t operator()( const A& ) const { return 0; }
>> };
>> }
>>
>> int main()
>> {
>> __gnu_cxx::hash_set<A> ahash_set;
>>
>> std::vector<A> tvec, tvec1;
>> std::copy(ahash_set.begin(),
>> ahash_set.end(),
>> std::back_inserter(tvec));
>> }
>>
>> HTH, Daniel
>>
>> _______________________________________________
>> Unsubscribe & other changes:
>> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


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