Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call of overloaded ‘pow(const double&, double)’ is ambiguous

I am new to C++, here is my problem : I need this quantity :

h = pow(mesh.V()[i0],1.0/3);

but I get this error message whenever I compile the program :

    call of overloaded ‘pow(const double&, double)’ is ambiguous

And if I write

double V = mesh.V()[i0];
h = pow(V,1.0/3);

I get :

    call of overloaded ‘pow(double&, double)’ is ambiguous

Now I think I understand what const double& and double& refer to,but how can I convert the const double& to a double?

Thanks!

like image 295
FYas Avatar asked Nov 03 '22 00:11

FYas


1 Answers

Now I think I understand what const double& and double& refer to,but how can I convert the const double& to a double?

Beware that some compilers use that syntax in error messages to represent something different than what it means in code. The error messages are telling you what the type used as the argument to the function is, rather than what the function takes.

If you want to get double in the error message you just need to call a function that returns by value a double, but that is not what you want.

What you need is to find out why the call is ambiguous. Is the compiler giving you later in the error message what function signatures are considered? It should, and reading the different overloads that it is considering will help in finding out why it is ambiguous in this context.

like image 109
David Rodríguez - dribeas Avatar answered Nov 09 '22 16:11

David Rodríguez - dribeas