Opened 21 years ago

Closed 21 years ago

#12 closed Bugs (Fixed)

Can't specify VertexPredicate

Reported by: nobody Owned by: jsiek
Milestone: Component: graph
Version: None Severity:
Keywords: Cc:

Description

From boost_1_25_1/boost/graph/filtered_graph.hpp, line
230:

template <typename Graph, typename EdgePredicate,
typename VertexPredicate>
  inline filtered_graph<Graph, EdgePredicate,
VertexPredicate>
  make_filtered_graph(Graph& g, EdgePredicate ep,
VertexPredicate vp) {
    return filtered_graph<Graph, EdgePredicate>(g, ep,
vp);
  }

make_filtered_graph is a template function, one of
whose template parameters is VertexPredicate. However,
the filtered_graph object returned by the function does
not make use of this type.

I propose that line 233 should read:

return filtered_graph<Graph, EdgePredicate,
VertexPredicate>(g, ep, vp);

I'm using g++ 2.95.3 on Solaris 2.8 for sparc. For the
following test case:

#include <boost/graph/filtered_graph.hpp>
#include <boost/graph/adjacency_list.hpp>
using namespace boost;

struct NotMuchOfAFilter
{
    template<class Vertex> bool operator()(Vertex key)
const { return true; }
};

int main()
{
    adjacency_list<> graph;

    make_filtered_graph(graph, keep_all(),
NotMuchOfAFilter());
}

g++ test.C -ftemplate-depth-30 -Iboost_1_25_1

yields:

boost_1_25_1/boost/graph/filtered_graph.hpp: In
function `class
boost::filtered_graph<boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>,boost::keep_all,NotMuchOfAFilter>
boost::make_filtered_graph<boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>,
boost::keep_all,
NotMuchOfAFilter>(boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>
&, boost::keep_all, NotMuchOfAFilter)':
test.C:14:   instantiated from here
boost_1_25_1/boost/graph/filtered_graph.hpp:233: no
matching function for call to
`boost::filtered_graph<boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>,boost::keep_all,boost::keep_all>::filtered_graph
(boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>
&, boost::keep_all &, NotMuchOfAFilter &)'
boost_1_25_1/boost/graph/filtered_graph.hpp:156:
candidates are:
boost::filtered_graph<boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>,boost::keep_all,boost::keep_all>::filtered_graph(const
boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>
&, boost::keep_all)
boost_1_25_1/boost/graph/filtered_graph.hpp:159:                
boost::filtered_graph<boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>,boost::keep_all,boost::keep_all>::filtered_graph(const
boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>
&, boost::keep_all, boost::keep_all)
boost_1_25_1/boost/graph/filtered_graph.hpp:219:                
boost::filtered_graph<boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>,boost::keep_all,boost::keep_all>::filtered_graph(const
boost::filtered_graph<boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>,boost::keep_all,boost::keep_all>
&)
boost_1_25_1/boost/graph/filtered_graph.hpp:233:
warning: control reaches end of non-void function
`boost::make_filtered_graph<boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>,
boost::keep_all,
NotMuchOfAFilter>(boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::no_property,boost::no_property,boost::no_property,boost::listS>
&, boost::keep_all, NotMuchOfAFilter)

Making the change I noted above causes the code to
compile and run correctly.

Keep up the good work on boost and the boost graph
library. Congratulations on the new book!

Change History (1)

comment:1 by jsiek, 21 years ago

Status: assignedclosed
Logged In: YES 
user_id=32836

Thanks for catching that! I've checked your suggested 
fix into CVS.
Note: See TracTickets for help on using tickets.