|
PECUNIA_EXPORT Money | absoluteValue (const Money &money) |
| Calculates the absolute value for the supplied amount of money.
|
|
template<template< typename, typename, typename, typename > typename AssociativeContainer, typename KeyType , typename ValueType , typename Compare = std::less<KeyType>, typename Allocator = std::allocator<std::pair<const KeyType, ValueType>>> |
Money | sum (const Currency &accumulateIn, const AssociativeContainer< KeyType, ValueType, Compare, Allocator > &elements, const std::optional< std::function< Money(const Money &money)> > &adjustor=std::nullopt) |
| Accumulates the total of all the supplied monies with the fewest possible number of conversions.
|
|
template<typename Container > |
Money | sum (const Currency &accumulateIn, const Container &elements, const std::optional< std::function< Money(const typename Container::value_type &)> > &mutator=std::nullopt) |
| Sums up a collection of monetary values, potentially transformed by a user-defined mutator function, with the fewest possible number of conversions.
|
|
template<template< typename, typename, typename, typename > typename AssociativeContainer, typename KeyType , typename ValueType , typename Compare = std::less<KeyType>, typename Allocator = std::allocator<std::pair<const KeyType, ValueType>>>
Money pecunia::math::sum |
( |
const Currency & | accumulateIn, |
|
|
const AssociativeContainer< KeyType, ValueType, Compare, Allocator > & | elements, |
|
|
const std::optional< std::function< Money(const Money &money)> > & | adjustor = std::nullopt ) |
|
nodiscard |
Accumulates the total of all the supplied monies with the fewest possible number of conversions.
- Precondition
- When an adjustor is supplied, it cannot be null.
- Template Parameters
-
AssociativeContainer | The associative container type holding the money. |
KeyType | The type the monies are keyed against, not used. |
ValueType | The value type in the container, which must include monetary amounts. |
Compare | The comparison type used for ordering elements in the container. |
Allocator | The allocator type used for memory management in the container. |
- Parameters
-
accumulateIn | The currency in which the final sum will be accumulated. |
elements | The container holding monetary pairs to be summed. |
adjustor | An optional function to adjust each monetary value during summation. If not provided, no adjustments are applied. |
- Returns
- The result of the summation as a monetary value in the specified currency.