--- Begin Message ---
Subject: |
Template problem |
Date: |
Mon, 02 Jul 2007 07:41:57 -0700 |
User-agent: |
G2/1.0 |
Hi,
I am trying to create a wrapper class for hash_sets. I would like to
use templates for the type of data that is stored in the hash_set, but
I get a strange compiler error. Everything works, if I don't use
templates. But with templates I get with g++ 4.1.2:
../TWTHashSet.h:42: error: type '__gnu_cxx::hash_set<PointerTemplate*,
CTWTHashSet<PointerTemplate>::pointerHashFunction,
CTWTHashSet<PointerTemplate>::pointerEquality,
std::allocator<PointerTemplate*> >' is not derived from type
'CTWTHashSet<PointerTemplate>'
../TWTHashSet.h:42: error: expected ';' before 'hash_setIterator'
I do not understand the error message. Could someone explain, what I
am doing wrong, or how I can solve that problem?
Thank you very much,
Benjamin Bihler
Source code:
TWTHashSet.cpp:
#include "TWTHashSet.h"
template< class PointerTemplate >
CTWTHashSet< PointerTemplate >::CTWTHashSet()
{
}
template< class PointerTemplate >
CTWTHashSet< PointerTemplate >::~CTWTHashSet()
{}
TWTHashSet.h:
#ifndef TWTHASHSET_H_
#define TWTHASHSET_H_
#include <ext/hash_set>
template< class PointerTemplate >
class CTWTHashSet
{
public:
CTWTHashSet();
~CTWTHashSet();
class pointerEquality;
class pointerHashFunction;
class pointerEquality
{
public:
bool operator()(const PointerTemplate *s1, const
PointerTemplate *s2) const
{
return (s1 == s2);
}
};
class pointerHashFunction
{
public:
size_t
operator()(const PointerTemplate *__x) const
{
return ( size_t )__x;
}
};
__gnu_cxx::hash_set< PointerTemplate*, pointerHashFunction,
pointerEquality, std::allocator< PointerTemplate* > > hsDreieckSet;
__gnu_cxx::hash_set< PointerTemplate*, pointerHashFunction,
pointerEquality, std::allocator< PointerTemplate* > >::iterator
hash_setIterator;
};
#endif /*TWTHASHSET_H_*/
--- End Message ---
--- Begin Message ---
Subject: |
confirm cdf2e62c937b77f20f17230ea4af3aa27edff558 |
If you reply to this message, keeping the Subject: header intact,
Mailman will discard the held message. Do this if the message is
spam. If you reply to this message and include an Approved: header
with the list password in it, the message will be approved for posting
to the list. The Approved: header can also appear in the first line
of the body of the reply.
--- End Message ---