Using standard math functions with template arguments in C++
<p>I wrote the code:</p>

<pre><code>const double PI = 3.141592653589793;

namespace 
{
    const int N = 8;
    const double points[8] = {-0.9602898564975363, -0.7966664774136267, -0.5255324099163290, -0.1834346424956498,
        0.1834346424956498, 0.5255324099163290, 0.7966664774136267, 0.9602898564975363};
    const double weights[8] = {0.1012285362903706, 0.2223810344533744, 0.3137066458778874, 0.3626837833783621, 0.3626837833783621,
        0.3137066458778874, 0.2223810344533744, 0.1012285362903706};
    const double error = 1e-10;

    template &lt;class TFunction, class TNumber&gt;
    class ChangeOfVariables
    {
        TFunction f;
    public:
        ChangeOfVariables(TFunction f) : f(f){}
        TNumber operator() (TNumber x) { TNumber c=std::cos(x); return f(std::tan(x))/(c*c); } 
    };
}


class Quadrature
{
public:
    Quadrature(void) {};
    ~Quadrature(void) {};

    template &lt;class TFunction, class TNumber&gt;
    TNumber integrate(TFunction f, TNumber a, TNumber b) 
    {
        TNumber result = 0.0;
        for(int i=0; i&lt;N; i++) 
        {
            result+= weights[i]*f(0.5*((b-a)*points[i]+(a+b)));
        }
        return 0.5*(b-a)*result;
    }

    template &lt;class TFunction, class TNumber&gt;
    TNumber integrateToInfty(TFunction f, TNumber a)
    {
        using std::atan; 
        return integrate&lt;ChangeOfVariables&lt;TFunction,TNumber&gt;, TNumber&gt;(ChangeOfVariables&lt;TFunction,TNumber&gt;(f), atan(a), PI/2); 
    }
};
</code></pre>

<p>which is used here:</p>

<pre><code>double dampendedExp(double x) {return std::exp(-2.0*x);}
int main()
{
    Quadrature quadrature;
    cout&lt;&lt;"e^(-2x)="&lt;&lt;quadrature.integrateToInfty(dampendedExp, 0)&lt;&lt;endl;
}
</code></pre>

<p>but the compiler complains:</p>

<pre><code>Error   1   error C2668: 'atan' : ambiguous call to overloaded function c:\users\ga1009\documents\dev\fouriertransform\fouriertransform\quadrature.h    48
</code></pre>

<p>The idea was to make it work for different number types, e.g. <code>double</code> and <code>complex&lt;double&gt;</code>, where atan is defined. How can I fix it?</p>
