#4715 closed Bugs (fixed)
custom property_map no longer works for astar_search
| Reported by: | Owned by: | Jeremiah Willcock | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | graph |
| Version: | Boost 1.44.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
After updating from boost 1.43 to 1.44 code calling astar_search with custom property map no longer compiles with error:
Error 2 error C2039: 'value_type' : is not a member of 'boost::property_traits<PA>' c:\libs\boost_1_44_0\boost\graph\astar_search.hpp 323
dijkstra_shortest_paths_no_color_map() with same property map still compiles correctly.
custom property map:
template <typename Functor, typename Arg>
struct function_property_map {
private:
Functor f;
public:
typedef typename boost::property_traits<
function_property_map<Functor, Arg>
>::value_type
value_type;
explicit function_property_map(const Functor& f): f(f) {}
friend value_type get(const function_property_map& pm, const Arg& x) {
return pm.f(x);
}
};
namespace boost {
template <typename Functor, typename Arg>
struct property_traits<function_property_map<Functor, Arg> > {
typedef typename boost::result_of<Functor(Arg)>::type value_type;
typedef value_type reference;
typedef Arg key_type;
typedef boost::readable_property_map_tag category;
};
}
template <typename Arg, typename Functor>
function_property_map<Functor, Arg>
make_function_property_map(const Functor& f) {
return function_property_map<Functor, Arg>(f);
}
Attachments (2)
Change History (19)
comment:1 by , 12 years ago
| Component: | None → graph |
|---|---|
| Owner: | set to |
comment:2 by , 12 years ago
| Owner: | changed from to |
|---|
comment:3 by , 12 years ago
by , 12 years ago
comment:4 by , 12 years ago
Extracted code for test. Also, I forgot to mention that I am building with Visual Studio 2008 SP1.
comment:5 by , 12 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
In my testing, you just need an extra include:
#include <boost/utility/result_of.hpp>
and then it compiles fine with GCC 4.1.2 and the Boost trunk.
comment:6 by , 12 years ago
This does not work for me and in fact original code had that file included.
Even replacing
namespace boost {
template <typename Functor, typename Arg>
struct property_traits<function_property_map<Functor, Arg> > {
typedef typename boost::result_of<Functor(Arg)>::type value_type;
typedef value_type reference;
typedef Arg key_type;
typedef boost::readable_property_map_tag category;
};
}
with
namespace boost {
template <typename Functor, typename Arg>
struct property_traits<function_property_map<Functor, Arg> > {
typedef int value_type;
typedef value_type reference;
typedef Arg key_type;
typedef boost::readable_property_map_tag category;
};
}
results with same error
comment:7 by , 12 years ago
What needs to be changed is the typedef for value_type in function_property_map. It should be
typedef typename boost::result_of<Functor(Arg)>::type value_type;
to avoid a potentially circular definition.
comment:8 by , 12 years ago
Still same error, even with both value_type typedefs (in function_property_map and property_traits) hardcoded to int.
I found that last working revision is 63530.
Briefly judging by revision's description, do I miss some const definitions?
comment:9 by , 12 years ago
Could you please post the entire error message (including the full instantiation stack)?
by , 12 years ago
| Attachment: | BuildLog.htm added |
|---|
comment:11 by , 12 years ago
Could you please try this patch:
Index: /u/jewillco/boost-svn/boost/graph/astar_search.hpp
===================================================================
--- /u/jewillco/boost-svn/boost/graph/astar_search.hpp (revision 65774)
+++ /u/jewillco/boost-svn/boost/graph/astar_search.hpp (working copy)
@@ -318,11 +318,11 @@
// otherwise the value type of the weight map.
typedef
typename detail::override_const_property_result<
- arg_pack_type, tag::weight_map, edge_weight_t, VertexListGraph>::type
+ arg_pack_type, tag::weight_map, edge_weight_t, const VertexListGraph>::type
weight_map_type;
typedef typename boost::property_traits<weight_map_type>::value_type W;
typedef
- typename detail::map_maker<VertexListGraph, arg_pack_type, tag::distance_map, W>::map_type
+ typename detail::map_maker<const VertexListGraph, arg_pack_type, tag::distance_map, W>::map_type
distance_map_type;
typedef typename boost::property_traits<distance_map_type>::value_type D;
@@ -355,7 +355,7 @@
BOOST_GRAPH_DECLARE_CONVERTED_PARAMETERS(params_type, params)
typedef
typename detail::override_const_property_result<
- arg_pack_type, tag::weight_map, edge_weight_t, VertexListGraph>::type
+ arg_pack_type, tag::weight_map, edge_weight_t, const VertexListGraph>::type
weight_map_type;
typedef typename boost::property_traits<weight_map_type>::value_type D;
astar_search_no_init
comment:14 by , 12 years ago
See if this patch works (either with or without the one I sent before):
Index: boost/graph/named_function_params.hpp
===================================================================
--- boost/graph/named_function_params.hpp (revision 65774)
+++ boost/graph/named_function_params.hpp (working copy)
@@ -392,8 +392,8 @@
template <typename ArgType, typename Prop, typename Graph, bool Exists>
struct override_const_property_t {
- typedef ArgType result_type;
- result_type operator()(const Graph&, const typename boost::add_reference<ArgType>::type a) const {return a;}
+ typedef typename boost::remove_const<ArgType>::type result_type;
+ result_type operator()(const Graph&, const ArgType& a) const {return a;}
};
template <typename ArgType, typename Prop, typename Graph>
comment:16 by , 12 years ago
| Resolution: | worksforme → fixed |
|---|

Could you please attach the full instantiation stack and/or a complete piece of code to test?