I'm trying to make my own math library with support for keeping stats on how many times each mathematical function in used. I would like all functions to have the same name as those in cmath so that I can easily just replace my math library header with cmath in my code and have it work the same way, just without the stats.
So far I've tried this:
my_math.hpp
float tanf(float ang);
my_math.cpp
#include <cmath>
float tanf(float ang)
{
std::cout << "Custom tanf() used..." << std::endl;
return std::tan((float)(ang));
}
Is this the best approach or is there a better one?
I've tried to use return std::tanf(ang)
but get the error that "tanf is not a member of std", even though I can use tanf in other parts of the code where I don't have my own tanf declared (I can never use std::tanf
though).
Is there a way to do this so that I can declare my own functions with the same name as the ones in cmath, add some functionality and then use the cmath version in the return?