slt à toute la communauté,
je suis nouveau ici et espère trouver des réponses à mes questions. Beh voilà, je travaille sur un projet de traitement d'images et nous utilisons STL et BOOST. Au départ j'avais déclarer une variable:
 
	
	map< boost::tuples::tuple<int, int, int>, float > mCellIndex;
 . 
Dans le souci d'optimiser la recherche dans ma map, j'ai changé la déclaration en hash_map:
	
	hash_map< boost::tuples::tuple<int, int, int>, float > mCellIndex2;
 .
Le problème est qu'il ya pas de hash fonction pour les tuples. Comment donc faire?.
Cependant en regardant dans le fichier: hash_func.h, j'ai écris un hash semblabe à celui des int, le voici:
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 
 | template<> 
   struct hash<boost::tuples::tuple<int, int, int> >
    { 
      size_t
      operator()(boost::tuples::tuple<int, int, int> __x) const
      { 
      	return  __x.get<0>()+ __x.get<1>()+ __x.get<2>();
      }
    }; | 
 et je l'ai déclaré avant la fonction main(). Cependant j'ai une érreur lors de la compilation:
../main.cpp:18: error: specialization of 'template<class _Key> struct __gnu_cxx::hash' in different namespace
/usr/include/c++/4.3/backward/hash_fun.h:71: error:   from definition of 'template<class _Key> struct __gnu_cxx::hash'
make: *** [main.o] Fehler 1.
Avez une idée du problème?, et comment contourner?
Merci d'avance
						
					
Partager