From help-request at octave dot org Thu Jul 14 05:18:27 2005 Subject: Re: basic DLD help? From: Shai Ayal To: "John W. Eaton" Cc: David Bateman , Paul Kienzle , help@octave.org Date: Thu, 14 Jul 2005 13:22:19 +0300 Ah, but what if I do want to change the data ? Shai John W. Eaton wrote: > On 13-Jul-2005, David Bateman wrote: > > | Even better would be > | > | const RowVector y(args(0).vector_value()); > | const double *py = y.fortran_vec(); > | > | since as you say fortran_vec calls make_unique except when "const", and > | since you aren't altering the data past to the function, in this manner > | you avoid a copy. > > Still better would be > > const RowVector y(args(0).vector_value()); > const double *py = y.data(); > > because if you are only asking for read-only access, you can use the > const data() method and avoid the call to make_unique(). > > As I recall, the reason for having different names (fortran_vec and > data) was because it was not possible to overload on const in early > C++ dialects. Now that it is possible, I suppose we could use just > one name instead of two. > > jwe > ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------