diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp index 118b889b..37238d36 100644 --- a/include/boost/numeric/ublas/matrix_expression.hpp +++ b/include/boost/numeric/ublas/matrix_expression.hpp @@ -330,17 +330,11 @@ namespace boost { namespace numeric { namespace ublas { // Swapping BOOST_UBLAS_INLINE - void swap (matrix_reference &v) { - if (this != &v) { - expression ().swap (v.expression ()); + void swap (matrix_reference &m) { + if (!same_closure (*this, m)) { + expression ().swap (m.expression ()); } } -#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS - BOOST_UBLAS_INLINE - friend void swap (matrix_reference &m1, matrix_reference &m2) { - m1.swap (m2); - } -#endif // Closure comparison BOOST_UBLAS_INLINE diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index f250cf81..65b2e397 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -345,16 +345,10 @@ namespace boost { namespace numeric { namespace ublas { // Swapping BOOST_UBLAS_INLINE void swap (vector_reference &v) { - if (this != &v) { + if (!same_closure (*this, v)) { expression ().swap (v.expression ()); } } -#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS - BOOST_UBLAS_INLINE - friend void swap (vector_reference &v1, vector_reference &v2) { - v1.swap (v2); - } -#endif // Closure comparison BOOST_UBLAS_INLINE