I read that the standard C++ way of using the maximum double value is std::numeric_limits<double>::max
.
Then in each of my functions where I want to initialize my doubles as the max double I use:
#include <limits>
#define MAX_DOUBLE (std::numeric_limits<double>::max)
Using gcc -pedantic -pedantic-errors -Wall -Wextra -Werror, I get the following error:
Cannot convert 'double (*)() noexcept' to 'double' in initialization
Can you explain this error?
Just as the error message said, you're using a function pointer (double (*)() noexcept
) as a double
directly. std::numeric_limits<double>::max
is declared as a function, you need to call it to get the value.
You can change
#define MAX_DOUBLE (std::numeric_limits<double>::max)
to
#define MAX_DOUBLE (std::numeric_limits<double>::max())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With