Boost logo

Boost Users :

Subject: [Boost-users] [Graph] No known conversion from int to vertex_iterator
From: Martin Magnusson (martin.magnusson_at_[hidden])
Date: 2012-07-04 15:23:54


I'm using BGL to store 3D triangle meshes, and I'm also using the ANN
lib to find nearest neighbours of mesh points. My code used to work,
using gcc 4.4 and BGL 1.40 (in Ubuntu 10.04), but since upgrading to gcc
4.6 and BGL 1.48 (in Ubuntu 12.04), my code doesn't compile anymore.

I cut down my code to a minimal (I think) example that shows my problem.
The attached code compiles with the old setup (I just get a warning that
adjacency_list.hpp uses a deprecated header), but it does not compile in
Ubuntu 12.04,

The compilation error I get is "no matching function for call to
'Mesh::Vertex_Iterator::Vertex_Iterator(const Mesh* const, unsigned int&)'"

The reason for that is that there is "no known conversion for argument 2
from 'unsigned int' to 'Mesh::Vertex_Graph_Iterator {aka
boost::range_detail::integer_iterator<unsigned int>}'"

Could anybody explain why, and what I can do to solve it? Is there any
way to create a boost::adjacency_list::vertex_iterator using an int in
the current version of BGL?

#include <boost/graph/adjacency_list.hpp>

class Mesh
{
public:

   typedef
   boost::property< boost::vertex_index1_t, int32_t, // The actual vertex
                    boost::property< boost::vertex_index2_t,
std::vector< unsigned int >, // Connected mesh faces
                                     boost::property<
boost::vertex_rank_t, bool > > > // Boundary flag
   Vertex_Properties;

   typedef boost::property< boost::edge_weight_t, double > Edge_Length;

   typedef boost::adjacency_list
   < boost::setS, // No parallel edges
     boost::vecS, // Loading gets painful if this is setS
     boost::undirectedS, // Edges are undirected
     Vertex_Properties, // Vertices store Vertex, faces & bnd. flag
     Edge_Length > // Edges store their length
   Vertex_Graph;

   typedef Vertex_Graph::vertex_iterator Vertex_Graph_Iterator;

   //---------------------------------------------------------------//
   // VERTEX ITERATOR:
   //---------------------------------------------------------------//
   class Vertex_Iterator : public boost::iterator_adaptor
   <Vertex_Iterator,
    Vertex_Graph_Iterator,
    int32_t,
    boost::bidirectional_traversal_tag>
   {
   public:
     Vertex_Iterator() {}

     Vertex_Iterator( const Mesh* const mesh,
                      Vertex_Graph_Iterator p )
       : its_parent (mesh),
         its_vertex (p)
     {}

     const Mesh* its_parent;
     Vertex_Graph_Iterator its_vertex;

   };

   void test_function() const;
};

void Mesh::test_function() const
{
   unsigned int i = 1;
   std::vector< Mesh::Vertex_Iterator > closest (10);
   closest[1] = Vertex_Iterator ( this, i ); //THIS IS THE PROBLEM
}

int main( int argc, char** argv )
{
   Mesh m;
   m.test_function();

   return 0;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net