From 0f4ecbcd4bd13743f74745257b95fabdbde33f0f Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Wed, 30 Jul 2014 12:01:19 +0400 Subject: [PATCH] Fix compilation with gcc 4.4 in C++11 mode Add constructor and assignment operator implementations for gcc 4.4 since it does not support defaulted move constructors and assignment. The operators are also used for gcc 4.5 for good measure (I cannot test it but gcc 4.6 does not need this workaround). Also the workaround is used for MSVC as well. The previous MSVC branch was incorrect since it did not invoke base class constructors and assignment. --- include/boost/graph/detail/adjacency_list.hpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/include/boost/graph/detail/adjacency_list.hpp b/include/boost/graph/detail/adjacency_list.hpp index c9c8f2ea..74723572 100644 --- a/include/boost/graph/detail/adjacency_list.hpp +++ b/include/boost/graph/detail/adjacency_list.hpp @@ -41,6 +41,7 @@ #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_GRAPH_MOVE_IF_POSSIBLE(x) (x) #else +#include #define BOOST_GRAPH_MOVE_IF_POSSIBLE(x) (std::move((x))) #endif @@ -295,11 +296,23 @@ namespace boost { inline stored_edge_property(Vertex target, const Property& p = Property()) : stored_edge(target), m_property(new Property(p)) { } -#if defined(BOOST_MSVC) - inline stored_edge_property(self&& x) {std::swap(m_property, x.m_property);}; - inline stored_edge_property(self const& x) {std::swap(m_property, const_cast(x).m_property);}; - inline self& operator=(self&& x) { std::swap(m_property, x.m_property); return *this;}; - inline self& operator=(self& x) { std::swap(m_property, x.m_property); return *this;}; +#if defined(BOOST_MSVC) || (defined(BOOST_GCC) && (BOOST_GCC / 100) < 406) + stored_edge_property(self&& x) : Base(static_cast< Base const& >(x)) { + m_property.swap(x.m_property); + } + stored_edge_property(self const& x) : Base(static_cast< Base const& >(x)) { + m_property.swap(const_cast(x).m_property); + } + self& operator=(self&& x) { + Base::operator=(static_cast< Base const& >(x)); + m_property = std::move(x.m_property); + return *this; + } + self& operator=(self& x) { + Base::operator=(static_cast< Base const& >(x)); + m_property = std::move(x.m_property); + return *this; + } #else stored_edge_property(self&& x) = default; self& operator=(self&& x) = default;