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:
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user