Simple solution for programmer, but not optimal for CPU time:
size_t sigfigs(double x)
{
return std::to_string(x).size();//create r-value string and get its size!
}
But you must take into account presence of "-" sign, dot, exponent, their sign and all possible combinations. I think, its impossible to create universal sigfigs() function, only problem specific.