[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: single/double precision in C++
From: |
John W. Eaton |
Subject: |
Re: single/double precision in C++ |
Date: |
Tue, 10 Nov 2009 06:56:30 -0500 |
On 10-Nov-2009, Jaroslav Hajek wrote:
| + // const_casts are necessary because LTFAT doesn't specify const on input
data.
| + lib_func (const_cast<T1 *>(f.fortran_vec ()), const_cast<T2
*>(gf.fortran_vec ()),
| + L, W, R, a, M, cout.fortran_vec ());
Maybe I'm missing something, but I don't see why the const_cast is
necessary here. The result of fortran_vec is not const.
The following compiles cleanly for me:
#include <octave/oct.h>
static void bar (double *) { }
DEFUN_DLD (foo, , , "")
{
Matrix m;
bar (m.fortran_vec ());
return octave_value_list ();
}
Changing the above to use
bar (m.data ());
would be a compile-time error because the data method returns
a const pointer. But casting away const there would not be the thing
to do unless you know that the called function does not modify its
argument. And in that case, you should really fix the prototype for
the called function, not cast away const.
jwe
- single/double precision in C++, Peter L., 2009/11/09
- Re: single/double precision in C++, Jaroslav Hajek, 2009/11/09
- Re: single/double precision in C++, Peter L., 2009/11/10
- Re: single/double precision in C++, Jaroslav Hajek, 2009/11/10
- Re: single/double precision in C++, Jaroslav Hajek, 2009/11/10
- Re: single/double precision in C++,
John W. Eaton <=
- Re: single/double precision in C++, Jaroslav Hajek, 2009/11/10
- Re: single/double precision in C++, John W. Eaton, 2009/11/10
- Re: single/double precision in C++, Jaroslav Hajek, 2009/11/10
- Re: single/double precision in C++, Peter Søndergaard, 2009/11/10
Re: single/double precision in C++, Sergei Steshenko, 2009/11/09