Boost C++ Libraries: Ticket #4715: custom property_map no longer works for astar_search https://svn.boost.org/trac10/ticket/4715 <p> After updating from boost 1.43 to 1.44 code calling astar_search with custom property map no longer compiles with error: </p> <p> Error 2 error C2039: 'value_type' : is not a member of 'boost::property_traits&lt;PA&gt;' c:\libs\boost_1_44_0\boost\graph\astar_search.hpp 323 </p> <p> dijkstra_shortest_paths_no_color_map() with same property map still compiles correctly. </p> <p> custom property map: </p> <pre class="wiki">template &lt;typename Functor, typename Arg&gt; struct function_property_map { private: Functor f; public: typedef typename boost::property_traits&lt; function_property_map&lt;Functor, Arg&gt; &gt;::value_type value_type; explicit function_property_map(const Functor&amp; f): f(f) {} friend value_type get(const function_property_map&amp; pm, const Arg&amp; x) { return pm.f(x); } }; namespace boost { template &lt;typename Functor, typename Arg&gt; struct property_traits&lt;function_property_map&lt;Functor, Arg&gt; &gt; { typedef typename boost::result_of&lt;Functor(Arg)&gt;::type value_type; typedef value_type reference; typedef Arg key_type; typedef boost::readable_property_map_tag category; }; } template &lt;typename Arg, typename Functor&gt; function_property_map&lt;Functor, Arg&gt; make_function_property_map(const Functor&amp; f) { return function_property_map&lt;Functor, Arg&gt;(f); } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4715 Trac 1.4.3 Szymon Gatner <szymon.gatner@…> Tue, 05 Oct 2010 23:49:45 GMT component changed; owner set https://svn.boost.org/trac10/ticket/4715#comment:1 https://svn.boost.org/trac10/ticket/4715#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Andrew Sutton</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">graph</span> </li> </ul> Ticket Jeremiah Willcock Wed, 06 Oct 2010 00:29:45 GMT owner changed https://svn.boost.org/trac10/ticket/4715#comment:2 https://svn.boost.org/trac10/ticket/4715#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Andrew Sutton</span> to <span class="trac-author">Jeremiah Willcock</span> </li> </ul> Ticket Jeremiah Willcock Wed, 06 Oct 2010 00:30:17 GMT <link>https://svn.boost.org/trac10/ticket/4715#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:3</guid> <description> <p> Could you please attach the full instantiation stack and/or a complete piece of code to test? </p> </description> <category>Ticket</category> </item> <item> <author>Szymon Gatner <szymon.gatner@…></author> <pubDate>Wed, 06 Oct 2010 08:00:53 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/4715 https://svn.boost.org/trac10/ticket/4715 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main.cpp</span> </li> </ul> Ticket Szymon Gatner <szymon.gatner@…> Wed, 06 Oct 2010 08:02:12 GMT <link>https://svn.boost.org/trac10/ticket/4715#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:4</guid> <description> <p> Extracted code for test. Also, I forgot to mention that I am building with Visual Studio 2008 SP1. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Wed, 06 Oct 2010 19:53:22 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4715#comment:5 https://svn.boost.org/trac10/ticket/4715#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> </ul> <p> In my testing, you just need an extra include: </p> <pre class="wiki">#include &lt;boost/utility/result_of.hpp&gt; </pre><p> and then it compiles fine with GCC 4.1.2 and the Boost trunk. </p> Ticket Szymon Gatner <szymon.gatner@…> Wed, 06 Oct 2010 21:05:58 GMT <link>https://svn.boost.org/trac10/ticket/4715#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:6</guid> <description> <p> This does not work for me and in fact original code had that file included. </p> <p> Even replacing </p> <pre class="wiki">namespace boost { template &lt;typename Functor, typename Arg&gt; struct property_traits&lt;function_property_map&lt;Functor, Arg&gt; &gt; { typedef typename boost::result_of&lt;Functor(Arg)&gt;::type value_type; typedef value_type reference; typedef Arg key_type; typedef boost::readable_property_map_tag category; }; } </pre><p> with </p> <pre class="wiki">namespace boost { template &lt;typename Functor, typename Arg&gt; struct property_traits&lt;function_property_map&lt;Functor, Arg&gt; &gt; { typedef int value_type; typedef value_type reference; typedef Arg key_type; typedef boost::readable_property_map_tag category; }; } </pre><p> results with same error </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Wed, 06 Oct 2010 21:09:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4715#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:7</guid> <description> <p> What needs to be changed is the typedef for value_type in <code>function_property_map</code>. It should be </p> <pre class="wiki">typedef typename boost::result_of&lt;Functor(Arg)&gt;::type value_type; </pre><p> to avoid a potentially circular definition. </p> </description> <category>Ticket</category> </item> <item> <author>Szymon Gatner <szymon.gatner@…></author> <pubDate>Wed, 06 Oct 2010 21:41:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4715#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:8</guid> <description> <p> Still same error, even with both value_type typedefs (in function_property_map and property_traits) hardcoded to int. </p> <p> I found that last working revision is 63530. </p> <p> Briefly judging by revision's description, do I miss some const definitions? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Wed, 06 Oct 2010 23:15:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4715#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:9</guid> <description> <p> Could you please post the entire error message (including the full instantiation stack)? </p> </description> <category>Ticket</category> </item> <item> <author>Szymon Gatner <szymon.gatner@…></author> <pubDate>Wed, 06 Oct 2010 23:42:40 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/4715 https://svn.boost.org/trac10/ticket/4715 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">BuildLog.htm</span> </li> </ul> Ticket Szymon Gatner <szymon.gatner@…> Wed, 06 Oct 2010 23:44:08 GMT <link>https://svn.boost.org/trac10/ticket/4715#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:10</guid> <description> <p> VS build log attached </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Wed, 06 Oct 2010 23:57:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4715#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:11</guid> <description> <p> Could you please try this patch: </p> <pre class="wiki">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&lt; - arg_pack_type, tag::weight_map, edge_weight_t, VertexListGraph&gt;::type + arg_pack_type, tag::weight_map, edge_weight_t, const VertexListGraph&gt;::type weight_map_type; typedef typename boost::property_traits&lt;weight_map_type&gt;::value_type W; typedef - typename detail::map_maker&lt;VertexListGraph, arg_pack_type, tag::distance_map, W&gt;::map_type + typename detail::map_maker&lt;const VertexListGraph, arg_pack_type, tag::distance_map, W&gt;::map_type distance_map_type; typedef typename boost::property_traits&lt;distance_map_type&gt;::value_type D; @@ -355,7 +355,7 @@ BOOST_GRAPH_DECLARE_CONVERTED_PARAMETERS(params_type, params) typedef typename detail::override_const_property_result&lt; - arg_pack_type, tag::weight_map, edge_weight_t, VertexListGraph&gt;::type + arg_pack_type, tag::weight_map, edge_weight_t, const VertexListGraph&gt;::type weight_map_type; typedef typename boost::property_traits&lt;weight_map_type&gt;::value_type D; astar_search_no_init </pre> </description> <category>Ticket</category> </item> <item> <author>Szymon Gatner <szymon.gatner@…></author> <pubDate>Thu, 07 Oct 2010 00:41:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4715#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:12</guid> <description> <p> No luck. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 07 Oct 2010 21:17:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4715#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:13</guid> <description> <p> Any other way I could help? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Thu, 07 Oct 2010 22:33:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4715#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:14</guid> <description> <p> See if this patch works (either with or without the one I sent before): </p> <pre class="wiki">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 &lt;typename ArgType, typename Prop, typename Graph, bool Exists&gt; struct override_const_property_t { - typedef ArgType result_type; - result_type operator()(const Graph&amp;, const typename boost::add_reference&lt;ArgType&gt;::type a) const {return a;} + typedef typename boost::remove_const&lt;ArgType&gt;::type result_type; + result_type operator()(const Graph&amp;, const ArgType&amp; a) const {return a;} }; template &lt;typename ArgType, typename Prop, typename Graph&gt; </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 08 Oct 2010 17:31:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4715#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:15</guid> <description> <p> That works even without first patch applied. Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Fri, 08 Oct 2010 17:33:23 GMT</pubDate> <title>resolution changed https://svn.boost.org/trac10/ticket/4715#comment:16 https://svn.boost.org/trac10/ticket/4715#comment:16 <ul> <li><strong>resolution</strong> <span class="trac-field-old">worksforme</span> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/65836" title="Fixed const issue on VC++ 8; fixes #4715">[65836]</a>) Fixed const issue on VC++ 8; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4715" title="#4715: Bugs: custom property_map no longer works for astar_search (closed: fixed)">#4715</a> </p> Ticket Jeremiah Willcock Fri, 08 Oct 2010 18:07:13 GMT <link>https://svn.boost.org/trac10/ticket/4715#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4715#comment:17</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/65839" title="Merged r65836 (fix for #4715) from trunk; refs #4715">[65839]</a>) Merged <a class="changeset" href="https://svn.boost.org/trac10/changeset/65836" title="Fixed const issue on VC++ 8; fixes #4715">r65836</a> (fix for <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4715" title="#4715: Bugs: custom property_map no longer works for astar_search (closed: fixed)">#4715</a>) from trunk; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4715" title="#4715: Bugs: custom property_map no longer works for astar_search (closed: fixed)">#4715</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>