Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting/deducing type in template-function for return value
    primarykey
    data
    text
    <p>I am using the Boost Graph Library and have build my own classes upon that.</p> <p>Now, I have the following function:</p> <pre><code>template&lt; class VERTEXPROPERTIES &gt; VERTEXPROPERTIES&amp; properties(const Vertex&amp; v) const { typename property_map&lt;FilteredGraphContainer, vertex_properties_t&gt;::const_type param = get(vertex_properties, graph_); return param[v]; } </code></pre> <p>When I use this function in a class template like this:</p> <pre><code>template&lt; class VERTEXPROPERTIES, class EDGEPROPERTIES &gt; class Graph { // all the code }; </code></pre> <p>it works. However, when I want to use it in a class like this:</p> <pre><code>template &lt; class GRAPH, class EDGE_PREDICATE, class VERTEX_PREDICATE &gt; class FilteredGraph { // all the code }; </code></pre> <p>and apply the properties() function to a FilteredGraph object, the compiler complains that it can't find the function.<br> As far as I have found out so far this is probably due to the missing template-parameter in the arguments list.<br> For the Graph-class, this template-parameter is easy to find out, as it gets defined when creating a Graph-object.<br> But for the FilteredGraph, it should be able to deduce it from the GRAPH-template parameter.<br> Then again, I think that the compiler nevertheless will have problems getting the right return-value type as this might probably be necessary to find out beforehand...<br> I would really like to keep that concept with the properties() function as it allows to keep the other functions generic.<br> Do you have any ideas how to solve that issue, possibly keeping the concept?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload