[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-users
Subject:    Re: [Boost-users] pow math function and bind in boost::lambda
From:       Conoscenza Silente <abruzzoforteegentile () gmail ! com>
Date:       2009-11-30 11:53:08
Message-ID: bf2c6e390911300353m192d0353r8c354738fe0e6310 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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<double (*)(double>(pow)) or create a
> polymorphic function object that calls pow.
>
> Roman Perepelitsa.
>
>
> 2009/11/30 Conoscenza Silente <abruzzoforteegentile@gmail.com>
>
>> 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 <abruzzoforteegentile@gmail.com>
>>>
>>> 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
>

[Attachment #5 (text/html)]

<div>Hi Roman</div>Thank you very much!<div>I tried to do that previously but without \
success using the following statement</div><div><br></div><div><span \
class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; \
border-collapse: collapse; ">boost::lambda::bind&lt; double &gt;( pow, tmp - h - g , \
3.15 )</span></div> <div><font class="Apple-style-span" face="arial, \
sans-serif"><span class="Apple-style-span" style="border-collapse: \
collapse;"><br></span></font></div><div><span class="Apple-style-span" \
style="font-size: 13px; "></span><font class="Apple-style-span" face="arial, \
sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">but \
reading the documentation I realized that it is something that can be applied only to \
functors.</span></font></div> <div><font class="Apple-style-span" face="arial, \
sans-serif"><span class="Apple-style-span" style="border-collapse: \
collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, \
sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">Using \
casting works fine.</span></font></div> <div><font class="Apple-style-span" \
face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: \
collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, \
sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">Thank \
you very much</span></font></div> <div><font class="Apple-style-span" face="arial, \
sans-serif"><span class="Apple-style-span" style="border-collapse: \
collapse;">CS<br></span></font><br><div class="gmail_quote">On Mon, Nov 30, 2009 at \
12:00 PM, Roman Perepelitsa <span dir="ltr">&lt;<a \
href="mailto:roman.perepelitsa@gmail.com">roman.perepelitsa@gmail.com</a>&gt;</span> \
wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex;"><div><span style="font-family:&#39;Times New \
Roman&#39;;font-size:medium"><pre style="word-wrap:break-word;white-space:pre-wrap"> \
could not deduce template argument for &#39;overloaded function type&#39; from \
&#39;overloaded function type&#39;</pre> </span></div><div>That&#39;s because \
function pow is overloaded. You should either explicitly cast it (replace pow with \
static_cast&lt;double (*)(double&gt;(pow)) or create a polymorphic function object \
that calls pow.</div>

<div><br></div><font color="#888888">Roman Perepelitsa.</font><div><div></div><div \
class="h5"><br><br><div class="gmail_quote">2009/11/30 Conoscenza Silente <span \
dir="ltr">&lt;<a href="mailto:abruzzoforteegentile@gmail.com" \
target="_blank">abruzzoforteegentile@gmail.com</a>&gt;</span><br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> The problem is that It does&#39;t compile.<div><div>I used \
MSVC++ Express.</div><div>The error in the attached file is generated only by that \
code.</div><div><br><br><div class="gmail_quote"><div><div></div><div> On Mon, Nov \
30, 2009 at 11:30 AM, Roman Perepelitsa <span dir="ltr">&lt;<a \
href="mailto:roman.perepelitsa@gmail.com" \
target="_blank">roman.perepelitsa@gmail.com</a>&gt;</span> wrote:<br> \
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"><div><div></div><div><div class="gmail_quote">2009/11/30 \
Conoscenza Silente <span dir="ltr">&lt;<a \
href="mailto:abruzzoforteegentile@gmail.com" \
target="_blank">abruzzoforteegentile@gmail.com</a>&gt;</span><div>


<div></div><div><br><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"> Hi All<div>I tried to use pow \
function from &lt;cmath&gt; in a lamda function using boost::lamdba.</div><div>Below \
the piece of code I used. </div><div>Do you know what is wrong with \
it?</div><div>Thank you very much.</div>




<div>CS</div><div><br></div><div><div>double l_tmp;</div><div>double \
p_tmp;</div><div><br></div><div>constant_type&lt;double&gt;::type h( constant(2.3) \
);</div><div>constant_type&lt;double&gt;::type g( constant(1.2) );<span \
style="white-space:pre">		</span></div>




<div><br></div><div>var_type&lt;double&gt;::type tmp( var(l_tmp) \
);</div><div>var_type&lt;double&gt;::type pow_tmp( var(p_tmp) \
);</div><div><br></div><div>std::for_each( x.begin(), x.end(),(</div><div><span \
style="white-space:pre">	</span>tmp = 10,</div>




<div><span style="white-space:pre">	</span>pow_tmp = boost::lambda::bind( pow, tmp - \
h - g , 3.15 )</div><div><span \
style="white-space:pre">			</span>));</div></div></blockquote><div><br></div></div></div><div>Does \
it compile? If not, can you post an error message? If it compiles, do you encounter \
any problems in run time?</div>



<div><br></div><font color="#888888"><div>Roman Perepelitsa. </div></font></div>
<br></div></div>_______________________________________________<br>
Boost-users mailing list<br>
<a href="mailto:Boost-users@lists.boost.org" \
target="_blank">Boost-users@lists.boost.org</a><br> <a \
href="http://lists.boost.org/mailman/listinfo.cgi/boost-users" \
target="_blank">http://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br></blockquote></div><br></div></div>
 <br>_______________________________________________<br>
Boost-users mailing list<br>
<a href="mailto:Boost-users@lists.boost.org" \
target="_blank">Boost-users@lists.boost.org</a><br> <a \
href="http://lists.boost.org/mailman/listinfo.cgi/boost-users" \
target="_blank">http://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br></blockquote></div><br>
 </div></div><br>_______________________________________________<br>
Boost-users mailing list<br>
<a href="mailto:Boost-users@lists.boost.org">Boost-users@lists.boost.org</a><br>
<a href="http://lists.boost.org/mailman/listinfo.cgi/boost-users" \
target="_blank">http://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br></blockquote></div><br></div>




_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic