I would suggest to override +
, -
, *
, /
operators and sqrt
function for some float-like type, in which you can count their use.
Something like this:
struct Double {
double val;
Double(double v): val(v) {}
static unsigned add_count = 0;
Double operator+(Double other) {
++add_count;
return Double(val + other.val);
}
};
do_your_stuff<Double>();