C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

utilisation des hash_set pour les objets

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
ckadi-nospam
Guest





PostPosted: Wed Jul 23, 2003 4:14 pm    Post subject: utilisation des hash_set pour les objets Reply with quote



Bonjour,

Je suis sous linux Mandarake 8.2 et je souhaite utiliser les hashtables
pour y mettre des objets autre que les types de base.

lors de l'utilisationde hash_set, le compilateur me rejette avec les
erreurs suivantes :

g++ -DHAVE_CONFIG_H -I. -I. -I.. -O2 -fno-exceptions -fno-check-new -c
contextsession.cpp

In file included from /usr/include/c++/3.2/backward/hash_set.h:59,
from contextsession.cpp:27:
/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning
This file includes at least one deprecated or antiquated header. Please
consider using one of the 32 headers found in section 17.4.1.2 of the
C++ standard. Examples include substituting the <X> header for the <X.h>
header for C++ includes, or <sstream> instead of the deprecated header
<strstream.h>. To disable this warning use -Wno-deprecated.
/usr/include/c++/3.2/bits/stl_function.h: In instantiation of
`std::_Identity<const ContextSession>':
/usr/include/c++/3.2/ext/stl_hashtable.h:266: instantiated from
`__gnu_cxx::hashtable<const ContextSession, const ContextSession,
__gnu_cxx::hash ContextSession>, equalsCTX, std::allocator<const ContextSession> >'
/usr/include/c++/3.2/ext/hash_set:107: instantiated from
`__gnu_cxx::hash_set<const ContextSession, __gnu_cxx::hash ContextSession>, equalsCTX, std::allocator<const ContextSession> >'
contextsession.cpp:210: instantiated from here
/usr/include/c++/3.2/bits/stl_function.h:481: `const _Tp&
std::_Identity<_Tp>::operator()(const _Tp&) const [with _Tp = const
ContextSession]' and `_Tp& std::_Identity<_Tp>::operator()(_Tp&) const
[with _Tp = const ContextSession]' cannot be overloaded
/usr/include/c++/3.2/bits/stl_alloc.h: In instantiation of
`std::allocator<const ContextSession>':
/usr/include/c++/3.2/ext/hash_set:130: instantiated from
`__gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc>::hash_set()
[with _Value = const ContextSession, _HashFcn = __gnu_cxx::hash<const
ContextSession>, _EqualKey = equalsCTX, _Alloc = std::allocator<const
ContextSession>]'
contextsession.cpp:210: instantiated from here
/usr/include/c++/3.2/bits/stl_alloc.h:636: `const _Tp*
std::allocator<_Alloc>::address(const _Tp&) const [with _Tp = const
ContextSession]' and `_Tp* std::allocator<_Alloc>::address(_Tp&) const
[with _Tp = const ContextSession]' cannot be overloaded
gmake: *** [contextsession.o] Erreur 1
*** échec ***

Back to top
ckadi-nospam
Guest





PostPosted: Thu Jul 31, 2003 12:12 pm    Post subject: Re: utilisation des hash_set pour les objets Reply with quote



Bonjour,

J'ai finalement utilise les hash-map qui gere les objets.
pou que ca marche:

il faut creer un typedef :

typedef hash_map<const char*, Obj hash TObject;

creer une varibale pour le type d'objets a gerer :
TObject; liste_obj;


ensuite, il faut declarer un iterateur :
TObject::iterator iter=liste_obj.find(key);




[email]kanze (AT) gabi-soft (DOT) fr[/email] wrote:
Quote:
ckadi-nospam <ckadi-NOSPAM (AT) mixcom (DOT) fr> wrote in message
news:<bfm57o$5sh$1 (AT) s1 (DOT) read.news.oleane.net>...


Je suis sous linux Mandarake 8.2 et je souhaite utiliser les
hashtables pour y mettre des objets autre que les types de base.


lors de l'utilisationde hash_set, le compilateur me rejette avec les
erreurs suivantes :


Ça aurait aidé si tu avais fourni le code qui a déclenché l'erreur. Mais
à juger d'après les messages d'erreur, tu as essayé à utiliser un :

__gnu_cxx::hash_set< ContextSession const

Ça ne marche pas. Le contenu d'un hash_set sont toujours const, et
l'implémentation utilise d'autres éléments qui surcharge sur le const.
Il suffit de faire :

__gnu_cxx::hash_set< ContextSession

En général, la norme ne permet pas l'instantiation d'une collection sur
un type const.

--
James Kanze GABI Software mailto:kanze (AT) gabi-soft (DOT) fr
Conseils en informatique orientée objet/ http://www.gabi-soft.fr
Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France, +33 (0)1 30 23 45 16


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.