# HG changeset patch # User jwe # Date 1057945601 0 # Node ID 75ee1995d2b49fca4949ced2d6b7240a17763f02 # Parent 2274f58d9b800c79f8c4cf509d2387bda25b1735 [project @ 2003-07-11 17:46:41 by jwe] diff --git a/liboctave/Array.h b/liboctave/Array.h --- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -48,6 +48,13 @@ // all the derived classes. template +T +resize_fill_value (const T& x) +{ + return x; +} + +template class Array { @@ -253,11 +260,11 @@ Array value (void); Array index (idx_vector& i, int resize_ok = 0, - const T& rfv = Array::resize_fill_value ()) const; + const T& rfv = resize_fill_value (T ())) const; #endif - static T resize_fill_value (void) { return T (); } + // static T resize_fill_value (void) { return T (); } void print_info (std::ostream& os, const std::string& prefix) const; }; @@ -266,11 +273,13 @@ int assign (Array& lhs, const Array& rhs, const LT& resize_fill_value); + template int assign (Array& lhs, const Array& rhs) { - return assign (lhs, rhs, Array::resize_fill_value ()); + // return assign (lhs, rhs, Array::resize_fill_value ()); + return assign (lhs, rhs, resize_fill_value (LT ())); } #endif diff --git a/liboctave/Array2-idx.h b/liboctave/Array2-idx.h --- a/liboctave/Array2-idx.h +++ b/liboctave/Array2-idx.h @@ -56,8 +56,7 @@ template Array2 -Array2::index (idx_vector& idx_arg, int resize_ok, - const T& resize_fill_value) const +Array2::index (idx_vector& idx_arg, int resize_ok, const T& rfv) const { Array2 retval; @@ -152,7 +151,7 @@ { int ii = idx_arg.elem (k++); if (ii >= orig_len) - retval.elem (i, j) = resize_fill_value; + retval.elem (i, j) = rfv; else { int fr = ii % nr; @@ -171,7 +170,7 @@ template Array2 Array2::index (idx_vector& idx_i, idx_vector& idx_j, int resize_ok, - const T& resize_fill_value) const + const T& rfv) const { Array2 retval; @@ -202,7 +201,7 @@ { int ii = idx_i.elem (i); if (ii >= nr || jj >= nc) - retval.elem (i, j) = resize_fill_value; + retval.elem (i, j) = rfv; else retval.elem (i, j) = elem (ii, jj); } @@ -497,14 +496,14 @@ int new_nr = max_row_idx > lhs_nr ? max_row_idx : lhs_nr; \ int new_nc = max_col_idx > lhs_nc ? max_col_idx : lhs_nc; \ \ - lhs.resize (new_nr, new_nc, resize_fill_value); \ + lhs.resize (new_nr, new_nc, rfv); \ } \ } \ while (0) template int -assign (Array2& lhs, const Array2& rhs, const LT& resize_fill_value) +assign (Array2& lhs, const Array2& rhs, const LT& rfv) { int retval = 1; diff --git a/liboctave/Array2.h b/liboctave/Array2.h --- a/liboctave/Array2.h +++ b/liboctave/Array2.h @@ -182,10 +182,10 @@ Array2 value (void); Array2 index (idx_vector& i, int resize_ok = 0, - const T& rfv = Array::resize_fill_value ()) const; + const T& rfv = resize_fill_value (T ())) const; Array2 index (idx_vector& i, idx_vector& j, int resize_ok = 0, - const T& rfv = Array::resize_fill_value ()) const; + const T& rfv = resize_fill_value (T ())) const; #endif @@ -200,7 +200,7 @@ int assign (Array2& lhs, const Array2& rhs) { - return assign (lhs, rhs, Array::resize_fill_value ()); + return assign (lhs, rhs, resize_fill_value (LT ())); } #endif diff --git a/liboctave/ArrayN.h b/liboctave/ArrayN.h --- a/liboctave/ArrayN.h +++ b/liboctave/ArrayN.h @@ -181,10 +181,10 @@ ArrayN value (void); ArrayN index (idx_vector& ra_idx, int resize_ok = 0, - const T& rfv = Array::resize_fill_value ()) const; + const T& rfv = resize_fill_value (T ())) const; ArrayN index (Array& ra_idx, int resize_ok = 0, - const T& rfv = Array::resize_fill_value ()) const; + const T& rfv = resize_fill_value (T ())) const; #endif }; @@ -197,7 +197,7 @@ int assign (ArrayN& lhs, const ArrayN& rhs) { - return assign (lhs, rhs, Array::resize_fill_value ()); + return assign (lhs, rhs, resize_fill_value (LT ())); } template diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2003-07-11 Russell Standish + + * Array.h (resize_fill_value): Now a top-level template function. + Accept object as argument. Change all uses. + 2003-07-09 John W. Eaton * Array-flags.cc, Array-flags.h (liboctave_pcv_flag): Delete. diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-07-11 Russell Standish + + * TEMPLATE-INST/Array-tc.cc (resize_fill_value): Provide + specialization. + 2003-07-10 John W. Eaton * strfns.cc (Fchar): Force string conversions without warnings. diff --git a/src/TEMPLATE-INST/Array-tc.cc b/src/TEMPLATE-INST/Array-tc.cc --- a/src/TEMPLATE-INST/Array-tc.cc +++ b/src/TEMPLATE-INST/Array-tc.cc @@ -27,6 +27,8 @@ #endif #include "Array.h" + + #include "Array.cc" #include "Array2.h" @@ -37,9 +39,8 @@ #include "oct-obj.h" -template<> -octave_value -Array::resize_fill_value (void) +octave_value +resize_fill_value (const octave_value& x) { static octave_value retval = octave_value (Matrix ()); return retval; @@ -47,6 +48,7 @@ template class Array; + template int assign (Array&, const Array&); template int assign (Array&,