2
0
mirror of https://github.com/boostorg/ublas.git synced 2026-02-20 15:12:16 +00:00

Mutable Expression concept requires:

assignment (default fails as reference type) and swap
 Use deep semantics as in a C++ reference


[SVN r25305]
This commit is contained in:
Michael Stevens
2004-09-21 13:41:57 +00:00
parent 12f9c0cf75
commit 3fbe29f6bc
2 changed files with 38 additions and 0 deletions

View File

@@ -275,6 +275,11 @@ namespace boost { namespace numeric { namespace ublas {
#endif
// Assignment
BOOST_UBLAS_INLINE
matrix_reference &operator = (const matrix_reference &m) {
expression ().operator = (m);
return *this;
}
template<class AE>
BOOST_UBLAS_INLINE
matrix_reference &operator = (const matrix_expression<AE> &ae) {
@@ -324,6 +329,20 @@ namespace boost { namespace numeric { namespace ublas {
return *this;
}
// Swapping
BOOST_UBLAS_INLINE
void swap (matrix_reference &v) {
if (this != &v) {
expression ().swap (v.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
bool same_closure (const matrix_reference &mr) const {

View File

@@ -289,6 +289,11 @@ namespace boost { namespace numeric { namespace ublas {
#endif
// Assignment
BOOST_UBLAS_INLINE
vector_reference &operator = (const vector_reference &v) {
expression ().operator = (v);
return *this;
}
template<class AE>
BOOST_UBLAS_INLINE
vector_reference &operator = (const vector_expression<AE> &ae) {
@@ -338,6 +343,20 @@ namespace boost { namespace numeric { namespace ublas {
return *this;
}
// Swapping
BOOST_UBLAS_INLINE
void swap (vector_reference &v) {
if (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
bool same_closure (const vector_reference &vr) const {