Boost logo

Boost Users :

Subject: Re: [Boost-users] [graph] Problem compiling simple graph code with recent g++
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-03-18 09:58:11


On Thu, 18 Mar 2010, Stephen Kell wrote:

> I'm having some problems with the Boost Graph library in 1.42.
> Specifically, if I include the graph concepts header before declaring my
> overloads of vertices, out_edges et al, the compiler can't see my
> overloads. I've produced a small-ish test case (below) which doesn't
> compile with g++ 4.4.3. (It's not supposed to link...)
>
> In file included from test.cpp:3:
> /home/srk31/opt/include/boost/graph/graph_concepts.hpp: In destructor ?boost::concepts::VertexListGraph<G>::~VertexListGraph() [with G = Gr]?:
> /home/srk31/opt/include/boost/graph/graph_concepts.hpp:166: instantiated from ?static void boost::concept::requirement<Model>::failed() [with Model = boost::concepts::VertexListGraphConcept<Gr>]?
> /home/srk31/opt/include/boost/concept_check.hpp:43: instantiated from ?void boost::function_requires(Model*) [with Model = boost::concepts::VertexListGraphConcept<Gr>]?
> test.cpp:49: instantiated from here
> /home/srk31/opt/include/boost/graph/graph_concepts.hpp:187: error: no matching function for call to ?vertices(Gr&)?
> /home/srk31/opt/include/boost/graph/graph_concepts.hpp: In member function ?void boost::concepts::VertexListGraph<G>::const_constraints(const G&) [with G = Gr]?:
> /home/srk31/opt/include/boost/graph/graph_concepts.hpp:189: instantiated from ?boost::concepts::VertexListGraph<G>::~VertexListGraph() [with G = Gr]?
> /home/srk31/opt/include/boost/graph/graph_concepts.hpp:166: instantiated from ?static void boost::concept::requirement<Model>::failed() [with Model = boost::concepts::VertexListGraphConcept<Gr>]?
> /home/srk31/opt/include/boost/concept_check.hpp:43: instantiated from ?void boost::function_requires(Model*) [with Model = boost::concepts::VertexListGraphConcept<Gr>]?
> test.cpp:49: instantiated from here
> /home/srk31/opt/include/boost/graph/graph_concepts.hpp:201: error: no matching function for call to ?vertices(const Gr&)?
>
> What's odd is that if I move the #include of
> boost/graph/graph_concepts.hpp to *below* my overloads, it does work.
> However, that code reordering is not an option in the actual context
> where I'm having this problem.
>
> Can anyone see anything wrong with my code, or verify that they do or
> don't see the same problem? I'm thinking it's a compiler bug but am not
> sure... will file it in gcc bugzilla if I'm not proved wrong here. It
> does build successfully with g++ 4.1.2. If anyone knows a workaround, or
> has other suggestions, I'd be very grateful. Anyway, thanks for reading!

Could you please try moving your functions outside the boost namespace?
Whether those are found depends on exactly where the caller is (I don't
think calls from boost::concept will find things in boost:: by default),
while having them in the same namespace as Gr would ensure that they are
found by ADL.

-- Jeremiah Willcock


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