Subject: [Boost-bugs] [Boost C++ Libraries] #9730: copy_graph doesn't use graph_traits
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-03-02 13:44:49
#9730: copy_graph doesn't use graph_traits
-----------------------------------------------+----------------------
Reporter: Masahiro Nawata <kamo.tanabota@â¦> | Owner: jewillco
Type: Bugs | Status: new
Milestone: To Be Determined | Component: graph
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
-----------------------------------------------+----------------------
copy_graph doesn't use graph_traits internally. Therefore, classes which
don't have traversal_category and directed_category, such as std::vector
or SGB, are not used as the source graph.
follow code is compile error:
{{{
#include <vector>
#include <list>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/vector_as_graph.hpp>
#include <boost/graph/copy.hpp>
int main()
{
using VectorGraph = std::vector<std::list<int>>;
auto vgraph = VectorGraph{{1, 2, 3}, {3, 5}, {5}, {4}, {0, 2},
{0}};
using Graph = boost::adjacency_list<>;
auto graph = Graph{};
boost::copy_graph(vgraph, graph
, boost::vertex_copy([](
boost::graph_traits<VectorGraph>::vertex_descriptor
,
boost::graph_traits<Graph>::vertex_descriptor) {})
. edge_copy([](
boost::graph_traits<VectorGraph>::edge_descriptor
,
boost::graph_traits<Graph>::edge_descriptor) {})
);
}
}}}
patch is here
{{{
--- /usr/local/include/boost/graph/copy.hpp 2014-03-02
21:44:55.000000000 +0900
+++ copy.hpp 2014-03-02 21:45:05.000000000 +0900
@@ -248,8 +248,8 @@
template <class Graph>
struct choose_graph_copy {
- typedef typename Graph::traversal_category Trv;
- typedef typename Graph::directed_category Dr;
+ typedef typename graph_traits<Graph>::traversal_category Trv;
+ typedef typename graph_traits<Graph>::directed_category Dr;
enum { algo =
(is_convertible<Trv, vertex_list_graph_tag>::value
&& is_convertible<Trv, edge_list_graph_tag>::value)
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9730> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC