KUMI v3.1.0
Exquisite Epidote
Loading...
Searching...
No Matches

◆ prod() [1/2]

template<concepts::product_type T>
auto kumi::prod ( T && t)
inlinenodiscardconstexpr

Computes the product of all elements.

On record types, this function operates on the underlying values, not on the fields themselves.

Parameters
tProduct 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 prod;
template<product_type T>
using prod_t = typename prod<T>::type;
}
constexpr auto prod(T &&t, Value init)
Computes the product of all elements.
Definition reduce.hpp:339

Computes the return type of a call to kumi::prod

Examples:

Tuple:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
auto t = kumi::tuple{2.,5,short{3},'\4'};
std::cout << kumi::prod(t, 10) << "\n";
std::cout << kumi::prod(t) << "\n";
}
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 = 5,"c"_id = short{3},"d"_id = '\4'};
std::cout << kumi::prod(r, 10) << "\n";
std::cout << kumi::prod(r) << "\n";
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36