I have the following piece of code:
#include <cmath>
float foo(float x, unsigned int m, float q = 0.0f)
{
return std::floorf(x * float(m) + q);
}
Now when I try to compile this with g++ 5.4.0 and options -std=c++11 I get an error saying ‘floorf’ is not a member of ‘std’.
Now it is my understanding that clause 26.8 of the C++11 standard mandates that the standard C++ library header <cmath> declare the same set of functions as the standard C library header <math.h>, albeit in the namespace std; and that clause 1.2 specifies that "C" is to be interpreted as C99; and that clause 7.12.9.2 of the C99 standard mandates that the standard C library header <math.h> declare a function float floorf(float).
So by that reasoning <cmath> should declare a function float std::floorf(float), which to the best of my knowledge should be a match for my code.
What gives? Am I missing something here?
(I know C++11 also defines a float std::floor(float); however, I've recently made the discovery that the f-suffixed variants of float functions are generally slightly faster, so I'd prefer to specifically invoke floorf().)
Aucun commentaire:
Enregistrer un commentaire