Considering a generic function, that accepts a count of numbers (usual + - * / algebra) and returns their average (sum over count), what requirements make sense to be imposed on the number to allow division by count?
(count is 2 in example pseudo code)
1. explicit construction from a single natural number:
(n1 + n2)/number(2)
2. straight up a division operator that accepts a natural number as second argument:
(n1 + n2)/2
3. multiplication identity constructor/value that can be accumulated (using addition) to reach count:
(n1 + n2)/(number::one + number::one)
4. addition operator that accepts a natural number as second argument (assuming zero/default constructor available):
(n1 + n2)/(number() + 2)
#cpp #programming #generic_programming