Problems using custom iterator with std::partial_sort_copy
I have written a custom iterator based on boost::iterator_facade, and I'm trying
to use this with the std::partial_sort_copy algorithm.
However, when compiling with g++ I get an error message saying that there is no
matching function for a call to counting_iterator(Vertex<3>&). The way I
interpret this is that my code is trying to construct a Vertex_Iterator from a
Vertex object, but that was not my intenton.
Is there something obvious that I have missed in my definition of
Vertex_Iterator, which should be a bidirectional iterator? A Vertex_Iterator
iterates over the vertices of a mesh, and therefore it needs a pointer to the
mesh in question. Does an iterator which returns a Vertex<3>& when dereferenced
need a constructor which takes only a Vertex<3>& argument? If so, how can I
supply it with the pointer to its parent mesh?
I hope that some of this makes sense.
//////////////////////////////////////////////
// Some typedefs from the parent class 'Mesh':
//////////////////////////////////////////////
class Mesh
{
public:
class Vertex_Iterator;
//...
private:
friend class Vertex_Iterator;
typedef boost::property< boost::vertex_root_t, Vertex<3> > Vertex_Property;
typedef boost::adjacency_list
< boost::vecS, boost::vecS, boost::undirectedS, Vertex_Property >
Vertex_Graph;
typedef boost::property_map
Martin Magnusson
I have written a custom iterator based on boost::iterator_facade, and I'm trying to use this with the std::partial_sort_copy algorithm.
However, when compiling with g++ I get an error message saying that there is no matching function for a call to counting_iterator(Vertex<3>&). The way I interpret this is that my code is trying to construct a Vertex_Iterator from a Vertex object, but that was not my intenton.
No, it's trying to create a counting_iterator. Why doubt the error message? Where that iterator is coming from, I can't tell you. The problem is that it's a counting_iterator over size_t values, and the code is initializing it with a Vertex<3>&. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (2)
-
David Abrahams
-
Martin Magnusson