Blog – John Wellbelove

Implementing a moving average

Known by many names, such as as Cumulative Moving Average, Rolling Average, Running Average, Moving Mean or Rolling Mean, the object is to update an average value on receipt of a new value over a set window size. Example: Imagine we have accumulated 10 values and our window size is 10.[ 1, 2, 3, 4, […]

Largest / Smallest. Part 2

In the last post i showed you how to implement a ‘Largest’ traits template using pre-C++11. In this post I will show you how to do the same using variadic templates. First we declare the ‘bare’ template. It tells the compiler that ‘Largest’ take an unknown number of template parameters. Next, we create helper templates […]

Largest / Smallest. Part 1

Sometimes, when multiple types are sent as template parameters, some information about the types needs to be interrogated to be able to configure another property of the template. The STL’s type traits header does a good job of supplying many of the more useful ones, but there is room for extension. Say, for instance, the […]

Next Page »