pow math function and bind in boost::lambda

Hi All I tried to use pow function from <cmath> in a lamda function using boost::lamdba. Below the piece of code I used. Do you know what is wrong with it? Thank you very much. CS double l_tmp; double p_tmp; constant_type<double>::type h( constant(2.3) ); constant_type<double>::type g( constant(1.2) ); var_type<double>::type tmp( var(l_tmp) ); var_type<double>::type pow_tmp( var(p_tmp) ); std::for_each( x.begin(), x.end(),( tmp = 10, pow_tmp = boost::lambda::bind( pow, tmp - h - g , 3.15 ) ));

2009/11/30 Conoscenza Silente
Hi All I tried to use pow function from <cmath> in a lamda function using boost::lamdba. Below the piece of code I used. Do you know what is wrong with it? Thank you very much. CS
double l_tmp; double p_tmp;
constant_type<double>::type h( constant(2.3) ); constant_type<double>::type g( constant(1.2) );
var_type<double>::type tmp( var(l_tmp) ); var_type<double>::type pow_tmp( var(p_tmp) );
std::for_each( x.begin(), x.end(),( tmp = 10, pow_tmp = boost::lambda::bind( pow, tmp - h - g , 3.15 ) ));
Does it compile? If not, can you post an error message? If it compiles, do you encounter any problems in run time? Roman Perepelitsa.

The problem is that It does't compile. I used MSVC++ Express. The error in the attached file is generated only by that code. On Mon, Nov 30, 2009 at 11:30 AM, Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote:
2009/11/30 Conoscenza Silente
Hi All
I tried to use pow function from <cmath> in a lamda function using boost::lamdba. Below the piece of code I used. Do you know what is wrong with it? Thank you very much. CS
double l_tmp; double p_tmp;
constant_type<double>::type h( constant(2.3) ); constant_type<double>::type g( constant(1.2) );
var_type<double>::type tmp( var(l_tmp) ); var_type<double>::type pow_tmp( var(p_tmp) );
std::for_each( x.begin(), x.end(),( tmp = 10, pow_tmp = boost::lambda::bind( pow, tmp - h - g , 3.15 ) ));
Does it compile? If not, can you post an error message? If it compiles, do you encounter any problems in run time?
Roman Perepelitsa.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

could not deduce template argument for 'overloaded function type' from
'overloaded function type'
That's because function pow is overloaded. You should either explicitly cast
it (replace pow with static_cast
The problem is that It does't compile. I used MSVC++ Express. The error in the attached file is generated only by that code.
On Mon, Nov 30, 2009 at 11:30 AM, Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote:
2009/11/30 Conoscenza Silente
Hi All
I tried to use pow function from <cmath> in a lamda function using boost::lamdba. Below the piece of code I used. Do you know what is wrong with it? Thank you very much. CS
double l_tmp; double p_tmp;
constant_type<double>::type h( constant(2.3) ); constant_type<double>::type g( constant(1.2) );
var_type<double>::type tmp( var(l_tmp) ); var_type<double>::type pow_tmp( var(p_tmp) );
std::for_each( x.begin(), x.end(),( tmp = 10, pow_tmp = boost::lambda::bind( pow, tmp - h - g , 3.15 ) ));
Does it compile? If not, can you post an error message? If it compiles, do you encounter any problems in run time?
Roman Perepelitsa.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi Roman Thank you very much! I tried to do that previously but without success using the following statement boost::lambda::bind< double >( pow, tmp - h - g , 3.15 ) but reading the documentation I realized that it is something that can be applied only to functors. Using casting works fine. Thank you very much CS On Mon, Nov 30, 2009 at 12:00 PM, Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote:
could not deduce template argument for 'overloaded function type' from 'overloaded function type'
That's because function pow is overloaded. You should either explicitly cast it (replace pow with static_cast
(pow)) or create a polymorphic function object that calls pow. Roman Perepelitsa.
2009/11/30 Conoscenza Silente
The problem is that It does't compile. I used MSVC++ Express. The error in the attached file is generated only by that code.
On Mon, Nov 30, 2009 at 11:30 AM, Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote:
2009/11/30 Conoscenza Silente
Hi All
I tried to use pow function from <cmath> in a lamda function using boost::lamdba. Below the piece of code I used. Do you know what is wrong with it? Thank you very much. CS
double l_tmp; double p_tmp;
constant_type<double>::type h( constant(2.3) ); constant_type<double>::type g( constant(1.2) );
var_type<double>::type tmp( var(l_tmp) ); var_type<double>::type pow_tmp( var(p_tmp) );
std::for_each( x.begin(), x.end(),( tmp = 10, pow_tmp = boost::lambda::bind( pow, tmp - h - g , 3.15 ) ));
Does it compile? If not, can you post an error message? If it compiles, do you encounter any problems in run time?
Roman Perepelitsa.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Conoscenza Silente
-
Roman Perepelitsa