Bonjour à tous,
dans le cadre de mon stage, je me suis recemment mis à fond au C++.
Ayant besoin de travailler sur des graphes, j'ai naturellement décidé de
me tourner vers la celebre bibliothèque BGL. Malheuresement, je rencontre
un problème : en essayant de surcharger les fonctions de la BGL pour ma propre classe
graphe (qui est en réalité une heightmap), il y a un appel que le compilo n'arrive pas
à résoudre :

Voici la fonction qui pose problème :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
template < typename UcharMap >
std::pair< typename graph_traits< Heightmap< UcharMap > >::adjacency_iterator, typename graph_traits< Heightmap< UcharMap > >::adjacency_iterator >
adjacent_vertices(typename graph_traits< Heightmap< UcharMap > >::vertex_descriptor vertex, const Heightmap< UcharMap >& hm) {
    return std::make_pair(HeightmapGraphAdjacencyIterator< UcharMap >(&hm, vertex, hm.getAdjacencyMask(vertex), hm.getFirstNeighbour(vertex)),
                          HeightmapGraphAdjacencyIterator< UcharMap >(&hm, vertex, 0, 8));
  }
Et c'est sur les deux appels aux constructeur de HeightmapGraphAdjacencyIterator que le compilateur bloque, voici son message :

./inc/Heightmap.hpp:413: error: no matching function for call to ‘boost::HeightmapGraphAdjacencyIterator<Map1D<unsigned char> >::HeightmapGraphAdjacencyIterator(const Heightmap<Map1D<unsigned char> >*, int, int, int)’
./inc/Heightmap.hpp:499: note: candidates are: boost::HeightmapGraphAdjacencyIterator<UcharMap>::HeightmapGraphAdjacencyIterator() [with UcharMap = Map1D<unsigned char>]
./inc/Heightmap.hpp:492: note: boost::HeightmapGraphAdjacencyIterator<UcharMap>::HeightmapGraphAdjacencyIterator(Heightmap<UcharMap>*, typename boost::graph_traits<Heightmap<UcharMap> >::vertex_descriptor, int, int) [with UcharMap = Map1D<unsigned char>] <near match>
./inc/Heightmap.hpp:481: note: boost::HeightmapGraphAdjacencyIterator<Map1D<unsigned char> >::HeightmapGraphAdjacencyIterator(const boost::HeightmapGraphAdjacencyIterator<Map1D<unsigned char> >&)

Comme on peut le voir, il ne trouve pas le bon constructeur à appeler, or le type vertex_descriptor de ma classe graphe est un int dans la structure graph_traits associée >.< d'ailleur la variable vertex est bien typé vertex_descriptor dans la fonction adjacent_vertices.

Voici le debut de la classe HeightmapGraphAdjacencyIterator qui montre le constructeur qui devrait être appelé et la déclaration d'amitié de la fonction adjacent_vertices :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
 
template < typename UcharMap >
  class HeightmapGraphAdjacencyIterator {
    typedef typename graph_traits< Heightmap< UcharMap > >::vertex_descriptor Vertex;
    const Heightmap< UcharMap >* map;
 
    Vertex vertex;
    int neighboursMask; // The ith bit of neighboursMask is 1 if vertex + map.adjacencyOffset(index) is a neighbour of vertex 
    int index; // vary from 0 to 7
 
    friend std::pair< typename graph_traits< Heightmap< UcharMap > >::adjacency_iterator, typename graph_traits< Heightmap< UcharMap > >::adjacency_iterator >
    adjacent_vertices<>(typename graph_traits< Heightmap< UcharMap > >::vertex_descriptor vertex, const Heightmap< UcharMap >& hm);
 
    HeightmapGraphAdjacencyIterator(Heightmap< UcharMap >* map, Vertex v, int mask, int index) : map(map), vertex(v), neighboursMask(mask), index(index) {
    }
[...]
Voici également le début de la structure graph_traits, ou l'on doit la définition du type vertex_descriptor :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
template < typename UcharMap >
  struct graph_traits< Heightmap< UcharMap > > {
    typedef int vertex_descriptor;
    [...]
Voila, je bloque la dessus =/ J'espere que quelqun arrivera à résoudre mon problème.
Merci d'avance !