No, no, no, that's bad - Octave just doesn't work this way. If you do
this, you can modify something else.
Consider:
b = my_b;
my_tr_solve (A, b);
if my_tr_solve uses const_cast on data (), my_b will still share the
data with b and will be also modified (!)
In short, you can use this method, in rare cases and *extremely*
carefully, if it's just an internal use and you *know* the variable
passed to the function is not aliased (a local temporary, for
instance).
But I advise you not to - if you really need to save memory at this
level, it's probably better to stay in C++ all the time.
There have been several discussions about the possibility of somehow
optimizing calls like x = myfunc (x), but it's not a trivial problem.
Ok, thank you. Your example
b = my_b;
my_tr_solve (A, b);
was the definitive argument for me. For read-only data I'll use data() method and for write I'll use fortran_vec().