Re: why do I need ::sin, not std::sin?

From: Alexander Stippler (stip_at_mathematik.uni-ulm.de)
Date: 06/04/04


Date: Fri, 04 Jun 2004 18:25:32 +0200

red floyd wrote:

> Alexander Stippler wrote:
>
>> Hi,
>>
>> simple question. Why does this not work:
>>
>> #include <algorithm>
>> #include <cmath>
>> #include <iostream>
>>
>> int
>> main()
>> {
>> double a[2];
>> a[0] = 0;a[1] = M_PI/2.;
>> std::transform(a, a+2, a, std::sin);
>> std::cout << a[0] << ", " << a[1] << std::endl;
>> return 0;
>> }
>>
>> for gcc and icc the type of the third argument of transform is unknown.
>> If I use the global ::sin it works fine. Why? I include cmath and there
>> sin is defined in namespace std, so why is it unknown?
>>
>> regards,
>> alex
>>
>
> IANAG (I am not a guru), and am probably way off base (please correct me
> guys -- please no flames).
>
> Isn't std::sin a template? Would you need to specifically instantiate
> std::sin, i.e.
>
> std::transform(a, a+2, a, std::sin<double>)
>
> You might also want to use std::ptr_fun as a wrapper to std::sin (or
 

std::transform(a, a+2, a, std::sin<double>)

What about this line if you have <complex> included? I took a look at the
<cmath> source code. It defines (in namespace std!) sin for float argument
as non template function, but the example above results in the same error
for float. I'm confused.

regards,
        alex

 



Relevant Pages

  • Re: Vista Media Center Crash
    ... Either the component that raises this event is not installed on your local computer or the installation is corrupted. ... P4: unknown ... it immediately crashes and sends a ...
    (microsoft.public.windows.mediacenter)
  • Re: The Minoan origin of the Phaistos disc
    ... >solution has to be SOMETHING NEW, UNKNOWN until now!... ... >NATURAL SUPPOSITION is to suppose that it's "a Minoan Calendar", ... calling to mind those eight name of months: ...
    (sci.archaeology)
  • Re: The Minoan origin of the Phaistos disc
    ... solution has to be SOMETHING NEW, UNKNOWN until now!... ... NATURAL SUPPOSITION is to suppose that it's "a Minoan Calendar", ... Regards ... > linguistic analyses demand an unreserved attitude to these ...
    (sci.archaeology)
  • Re: mailx: a lot of new mail
    ... But it is fairly new, and mailx, coming with Debian 3.0 ... Well, when I hit r to reply, I then hit ~m to include the original letter ... Unknown tilde escape. ...
    (comp.unix.questions)
  • Re: What everyone needs to know
    ... regards, Richard ... > Unknown wrote: ... > Self-anointed Moderator ...
    (microsoft.public.windowsxp.general)

Loading