Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] DistanceMatrix type for johnson_all_pairs_shortest_paths
From: Andrew Sutton (andrew.n.sutton_at_[hidden])
Date: 2009-09-10 07:20:33


>
>> const int V(num_vertices(g));
>> std::vector < int >d(V, (std::numeric_limits < int >::max)());
>> int D[V][V];
>> johnson_all_pairs_shortest_paths(g, D, distance_map(&d[0]));
>>
>> But this didn't compile, I got the error
>>
>> error: no matching function for call
>> to ‘johnson_all_pairs_shortest_paths(Graph&, int [(long int)V][(long
>> int)V], boost::bgl_named_params<int*, boost::vertex_distance_t,
>> boost::no_property>)’
>>
>
> I do not know how GCC handles the types of run-time sized arrays, which are
> compiler-specific in C++.

That's what the problem is... I couldn't see it. You can't instantiate a
template over the type of a variable length array. You can probably think of
it as a local type (a struct within a function), but it probably goes beyond
that. Last time I checked, calling typeid on e.g., D resulted in a compiler
error. That may have been GCC 4.1, though. Didn't GCC drop them at some
point?

This holds for linear arrays also. One more argument against variable length
arrays.

Andrew Sutton
andrew.n.sutton_at_[hidden]



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