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

◆ prod() [2/2]

template<product_type T, typename Value >
constexpr auto kumi::prod ( T &&  t,
Value  init 
)
inlineconstexpr

Computes the product of all elements.

Parameters
tProduct type to operate on
initInitial value of the product
Returns
The value of get<0>(t) * ... * get<N-1>(t) * init

Helper type

namespace kumi::result
{
template<product_type T, typename Value> struct prod;
template<product_type T, typename Value>
using prod_t = typename prod<T,Value>::type;
}
constexpr auto prod(T &&t, Value init)
Computes the product of all elements.
Definition reduce.hpp:294

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

Example

#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:37