|
Boost : |
From: Daniel Frey (d.frey_at_[hidden])
Date: 2006-02-19 19:01:05
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk