A specialization bug?
adah@sh163.net
adah@sh163.net
Fri Dec 28 03:46:00 GMT 2001
When testing with the following minimal test case:
-----------------------------------------------
#include <hash_map>
struct A
{
int i;
};
template<> struct std::hash<A>
{
size_t operator()(const A& x) const
{
return x.i;
}
};
int main(int argc, char *argv[])
{
return 0;
}
-----------------------------------------------
Gcc 2.95.3 in default configuration compiles it well. However, when
using STLport 4.5.1 (http://www.stlport.com), both MinGW and Cygwin
ports report:
test.cpp:9: specializing `struct _STL::hash<A>' in different
namespace
D:/STLport-4.5.1/stlport/stl/_hash_fun.h:40: from definition of
`template <class _Key> struct _STL::hash<_Key>'
I have to wrap the definition in namespace std to make it compile,
which seems against the C++ standard. My purpose is to define a
private class used as key of hash_map.
Should it be regarded as a bug of GCC?
Both Borland BCC 5.5.1 and Microsoft Visual C++ 6.0 will compile this
test case with STLport. Without STLport they will not since they have
no hash_map support, but it is clear they have no problems with this
kind of specialization.
Please reply to my personal e-mail address, too.
Best regards,
Wu Yongwei
More information about the Gcc-bugs
mailing list