Computes the sum of all elements.
On record types, this function operates on the underlying values, not on the fields themselves.
- Parameters
-
| t | Product type to operate on |
- Returns
- The value of get<0>(t) + ... + get<N-1>(t)
Helper type
namespace kumi::result
{
template<product_type T>
struct sum;
template<product_type Te>
}
constexpr auto sum(T &&t, Value init)
Computes the sum of all elements.
Definition reduce.hpp:268
Computes the return type of a call to kumi::sum
Examples:
Tuple:
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:33
Record:
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto r =
kumi::record{
"a"_id = 2.,
"b"_id = 1,
"c"_id =
short{55},
"d"_id =
' '};
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36