Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
accum8.cpp
Go to the documentation of this file.
1 
7 #include "accum8.hpp"
8 #include <iostream>
9 
10 template <typename T1, typename T2>
11 class MultPolicy
12 {
13 public:
14  static void accumulate(T1& total, const T2& value) { total *= value; }
15 };
16 
17 int main()
18 {
19  int num[] = {1, 2, 3, 4, 5};
20  std::cout << "the average value of the integer values is " << Accum<int>::accum(&num[0], &num[5]) / 5 << '\n';
21  std::cout << "the product of the integer values is " << Accum<int, MultPolicy>::accum(&num[0], &num[5]) << '\n';
22 
23  char name[] = "templates";
24  int length = sizeof(name) - 1;
25  std::cout << "the average value of the characters in \"" << name << "\" is "
26  << Accum<char>::accum(&name[0], &name[length]) / length << '\n';
27  return 0;
28 }
static AT::type accum(T const *beg, T const *end)
Definition: accum5.hpp:14
int main()
Definition: accum8.cpp:17