I wrote a simple moving average class that can be used with AVR.
template<typename T, typename Tsum = int32_t>
class MovingAverage { ... }
But now I want to specialize this class for float without copying and pasting the whole body of the class and changing all T and Tsum to float and that I do not need to use two template parameters. Tsum is the type of the variable "sum", where all transmitted values โโof type T are summed. If T is 'uint8_t', it is recommended to use "uint32_t" for the sum, but for float or double there is no need to use the data type with higher precision, therefore, for this purpose I want only one parameter. I thought this might work like this:
typedef MovingAverage<float, float> MovingAverage<float>
or as follows:
template<>
class MovingAverage<float> : public MovingAverage<float, float> {};
But I was wrong, and I only found solutions where I need to write my code twice.
, , ?
!