From 86bbbf563d1fe548dbc6bb327e74a5bef5160c30 Mon Sep 17 00:00:00 2001 From: BenPope Date: Mon, 21 Apr 2014 22:15:48 +0800 Subject: [PATCH 1/3] Fix directed_graph::swap --- include/boost/graph/directed_graph.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/graph/directed_graph.hpp b/include/boost/graph/directed_graph.hpp index 585308d1..2c56a4e0 100644 --- a/include/boost/graph/directed_graph.hpp +++ b/include/boost/graph/directed_graph.hpp @@ -307,7 +307,7 @@ public: void swap(directed_graph& g) { - m_graph.swap(g); + m_graph.swap(g.m_graph); std::swap(m_num_vertices, g.m_num_vertices); std::swap(m_max_vertex_index, g.m_max_vertex_index); std::swap(m_num_edges, g.m_num_edges); From 9b7fbc1a7669569cfc495a1376029746ce0ccfa9 Mon Sep 17 00:00:00 2001 From: BenPope Date: Wed, 14 May 2014 23:43:53 +0800 Subject: [PATCH 2/3] Add tests for member swap and fix undirected_graph<>::swap --- include/boost/graph/undirected_graph.hpp | 2 +- test/Jamfile.v2 | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/graph/undirected_graph.hpp b/include/boost/graph/undirected_graph.hpp index 5c000dc2..1db21a64 100644 --- a/include/boost/graph/undirected_graph.hpp +++ b/include/boost/graph/undirected_graph.hpp @@ -294,7 +294,7 @@ public: } void swap(undirected_graph& g) { - m_graph.swap(g); + m_graph.swap(g.m_graph); std::swap(m_num_vertices, g.m_num_vertices); std::swap(m_max_vertex_index, g.m_max_vertex_index); std::swap(m_num_edges, g.m_num_edges); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 5487631f..0523f100 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -79,6 +79,7 @@ test-suite graph_test : [ run adjacency_matrix_test.cpp ] [ compile vector_graph_cc.cpp ] [ compile copy.cpp ] + [ compile swap.cpp ] [ compile property_iter.cpp ] [ run bundled_properties.cpp ] [ run floyd_warshall_test.cpp ] From e2da814588371f90b3595780095b358e6e574d93 Mon Sep 17 00:00:00 2001 From: BenPope Date: Wed, 14 May 2014 23:46:25 +0800 Subject: [PATCH 3/3] Add tests for member swap and fix undirected_graph<>::swap --- test/swap.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/swap.cpp diff --git a/test/swap.cpp b/test/swap.cpp new file mode 100644 index 00000000..f47b234f --- /dev/null +++ b/test/swap.cpp @@ -0,0 +1,21 @@ +// Copyright (C) Ben Pope 2014. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +template +void test_member_swap() +{ + Graph lhs, rhs; + lhs.swap(rhs); +} + +int main() +{ + test_member_swap >(); + test_member_swap >(); + test_member_swap >(); +}