E
Enquiries, Hopkins Research
Hi all
I have a conundrum that is puzzling me.
I have a large codebase in C that I am converting to C++ as fast as possible
(i.e. slowly because I keep learning new idioms and stumbling with C++
'features'). One part of the C code is some optimisation functions that
expect a pointer to a function which is sent an array of doubles and returns
a double i.e. simplified..
void optimise( double (*funk)( double* ) );
I now have a bunch of classes with member functions which also take double*
and return double that I want to use in this optimiser, but the compiler
won't let me because:
error: argument of type 'double (namespace::class:(double*)' does not
match 'double (*)(double*)'
OK - I hadn't thought about that but felt there must be an easy answer.
However, I have tried declaring the functions in question as friends (but
the class members that the functions use are no longer available) and
sending 'pointers' to them a la BS TCPPPL p.419:
typedef double (class::*Pstd_mem)( double* pv );
Pstd_mem p = &class:pt_ll;
...but nothing I have tried so far works and I am running out of ideas. Can
any C++ gurus out there suggest a solution (that is hopefully reliable and
efficient)?
TIA and please CC replies here
Michael
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ _/ _/_/_/ Hopkins Research Ltd
_/ _/ _/ _/
_/_/_/_/ _/_/_/ http://www.hopkins-research.com/
_/ _/ _/ _/
_/ _/ _/ _/ 'touch the future'
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
I have a conundrum that is puzzling me.
I have a large codebase in C that I am converting to C++ as fast as possible
(i.e. slowly because I keep learning new idioms and stumbling with C++
'features'). One part of the C code is some optimisation functions that
expect a pointer to a function which is sent an array of doubles and returns
a double i.e. simplified..
void optimise( double (*funk)( double* ) );
I now have a bunch of classes with member functions which also take double*
and return double that I want to use in this optimiser, but the compiler
won't let me because:
error: argument of type 'double (namespace::class:(double*)' does not
match 'double (*)(double*)'
OK - I hadn't thought about that but felt there must be an easy answer.
However, I have tried declaring the functions in question as friends (but
the class members that the functions use are no longer available) and
sending 'pointers' to them a la BS TCPPPL p.419:
typedef double (class::*Pstd_mem)( double* pv );
Pstd_mem p = &class:pt_ll;
...but nothing I have tried so far works and I am running out of ideas. Can
any C++ gurus out there suggest a solution (that is hopefully reliable and
efficient)?
TIA and please CC replies here
Michael
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ _/ _/_/_/ Hopkins Research Ltd
_/ _/ _/ _/
_/_/_/_/ _/_/_/ http://www.hopkins-research.com/
_/ _/ _/ _/
_/ _/ _/ _/ 'touch the future'
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]