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

FIX ref returned reference to 0 pointer if new element. Thanks Max Weinberg.

[SVN r31247]
This commit is contained in:
Michael Stevens
2005-10-09 16:43:42 +00:00
parent 2c47c3d8d4
commit defbcdfe59
2 changed files with 8 additions and 6 deletions

View File

@@ -143,10 +143,11 @@ namespace boost { namespace numeric { namespace ublas {
// Conversion to reference - may be invalidated
BOOST_UBLAS_INLINE
value_type& ref () const {
pointer p = (*this) ().find_element (i_, i_);
const pointer p = (*this) ().find_element (i_, i_);
if (!p)
(*this) ().insert_element (i_, j_, value_type/*zero*/());
return *p;
return (*this) ().insert_element (i_, j_, value_type/*zero*/());
else
return *p;
}
private:

View File

@@ -141,10 +141,11 @@ namespace boost { namespace numeric { namespace ublas {
// Conversion to reference - may be invalidated
BOOST_UBLAS_INLINE
value_type& ref () const {
pointer p = (*this) ().find_element (i_);
const pointer p = (*this) ().find_element (i_);
if (!p)
(*this) ().insert_element (i_, value_type/*zero*/());
return *p;
return (*this) ().insert_element (i_, value_type/*zero*/());
else
return *p;
}
private: