Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] passing a graph from one function to another
From: r89 (r8921025_at_[hidden])
Date: 2008-11-25 14:13:30


Andrew Sutton-2 wrote:
>
>>
>> How should I do that? I wish I could do something like this:
>>
>> graph_t myGraph;
>>
>> fun_A(graph_t &myGraph) {
>> myGraph(array, edge_array + num_arcs, weights, num_nodes);
>> }
>>
>> fun_B(graph_t &myGraph) {
>> // using myGraph to run some graph algorithm...
>> }
>>
>>
> You can't invoke a constructor on an object that is already created -
> well,
> you probably can, but I seriously doubt that you want to. Instead, just
> return myGraph from fun_A:
>
> graph_t fun_A()
> { return graph_t(...); }
>
> func_B(graph_t& g)
> { ... }
>
> main()
> {
> graph_t g = fun_A();
> fun_B(g);
> }
>
> It might look like there's an unnecessary copy, but there won't be.
>
> Andrew Sutton
> andrew.n.sutton_at_[hidden]
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

I tried as you suggested, and it does work in Release mode (Visual Studio
2005), but NOT in Debug mode. Very strange.
The CPU keeps running at the line
return myGraph;
and does not go further. Any suggestions? Thanks!

-- 
View this message in context: http://www.nabble.com/-BGL--passing-a-graph-from-one-function-to-another-tp20582781p20687759.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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