Mercurial > hg > octave-lyh
diff liboctave/Array.cc @ 10075:84b0725f4b09
return class types by reference in const Array element access functions
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 08 Jan 2010 11:25:08 +0100 |
parents | bb30843c4929 |
children | eb8ac0eed9f1 |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -188,62 +188,36 @@ } template <class T> -T +T& Array<T>::range_error (const char *fcn, octave_idx_type n) const { (*current_liboctave_error_handler) ("%s (%d): range error", fcn, n); - return T (); -} - -template <class T> -T& -Array<T>::range_error (const char *fcn, octave_idx_type n) -{ - (*current_liboctave_error_handler) ("%s (%d): range error", fcn, n); static T foo; return foo; } template <class T> -T +T& Array<T>::range_error (const char *fcn, octave_idx_type i, octave_idx_type j) const { (*current_liboctave_error_handler) ("%s (%d, %d): range error", fcn, i, j); - return T (); -} - -template <class T> -T& -Array<T>::range_error (const char *fcn, octave_idx_type i, octave_idx_type j) -{ - (*current_liboctave_error_handler) - ("%s (%d, %d): range error", fcn, i, j); static T foo; return foo; } template <class T> -T +T& Array<T>::range_error (const char *fcn, octave_idx_type i, octave_idx_type j, octave_idx_type k) const { (*current_liboctave_error_handler) ("%s (%d, %d, %d): range error", fcn, i, j, k); - return T (); -} - -template <class T> -T& -Array<T>::range_error (const char *fcn, octave_idx_type i, octave_idx_type j, octave_idx_type k) -{ - (*current_liboctave_error_handler) - ("%s (%d, %d, %d): range error", fcn, i, j, k); static T foo; return foo; } template <class T> -T +T& Array<T>::range_error (const char *fcn, const Array<octave_idx_type>& ra_idx) const { std::ostringstream buf; @@ -264,31 +238,6 @@ (*current_liboctave_error_handler) (buf_str.c_str ()); - return T (); -} - -template <class T> -T& -Array<T>::range_error (const char *fcn, const Array<octave_idx_type>& ra_idx) -{ - std::ostringstream buf; - - buf << fcn << " ("; - - octave_idx_type n = ra_idx.length (); - - if (n > 0) - buf << ra_idx(0); - - for (octave_idx_type i = 1; i < n; i++) - buf << ", " << ra_idx(i); - - buf << "): range error"; - - std::string buf_str = buf.str (); - - (*current_liboctave_error_handler) (buf_str.c_str ()); - static T foo; return foo; }