Pecunia 0.9.0-alpha.22
Library using the ISO-4217 currency standard & a fixed monetary unit size
Loading...
Searching...
No Matches
pecunia::Money Class Reference

A representation of a country’s currency supporting basic arithmetic usage and guaranteeing all operations succeed without a loss of precision, overflow, or underflow. More...

#include <Money.hpp>

Collaboration diagram for pecunia::Money:

Public Member Functions

 Money ()
 Constructor for a fully formed object that initialises the stored amount to an unknown currency at zero.
 
 Money (const Currency &code)
 Constructor for a fully formed object that initialises the stored amount to zero of a specific currency.
 
 Money (const Currency &code, const MajorUnit &major, const MinorUnit &minor=0u, const MinorUnit &subMinor=0)
 Constructor for setting an exact monetary value of a fully formed object for a currency that expects a minor value.
 
 Money (const Currency &code, const MajorUnit &major, const std::optional< MinorUnit > &minor, const MinorUnit &subMinor=0)
 Constructor for setting an exact monetary value of a fully formed object for a currency that may support a minor value.
 
 Money (const FloatingPointRounderFunction &rounder, const Currency &code, const FloatingPointBase &value)
 Constructor for setting a monetary value using the native floating-point type.
 
 Money (const MajorUnit &major, const Currency &code)
 Constructor for setting an exact monetary value of a fully formed object. This is most useful for the currencies that never have minor units.
 
 Money (const MajorUnit &major, const MinorUnit &subMinor, const Currency &code)
 Constructor for setting an exact monetary value of a fully formed object. This is most useful for the currencies that never have minor units.
 
 Money (const Minor &m)
 Constructor for a fully formed object that initialises based on the currency’s minor value.
 
 Money (const Money &)=default
 
 Money (Money &&) noexcept=default
 
 ~Money ()=default
 
const MajorUnit & amount () const noexcept
 The entire representation of the monetary amount using the currency’s major unit, minor unit, and the sub-minor digits, in the form MajorMinorSub-minor.
 
Moneyassign (const Money &other) noexcept
 Assigns the value and currency from the provided object to the current instance.
 
Moneyassign (Money &&other) noexcept
 Assigns the value and currency from the provided object to the current instance.
 
void clear () noexcept
 Resets the object to its default state.
 
const Currencycode () const noexcept
 Accessor to the code the currency amount represents.
 
bool hasOnlyMinor () const noexcept
 Determines if the monetary amount consists of only minor units, i.e. only change.
 
MajorUnit major () const
 Accessor to the major monetary value, e.g. only the U.S.A. dollars.
 
std::optional< MinorUnit > minorOnly () const
 Accessor to the minor monetary value, e.g. the U.S.A. cents, truncating the fractional cents.
 
MinorUnit minorWithSub () const
 Accessor to the minor and sub-minor monetary value, e.g. the U.S.A. cents and fractional cents.
 
 operator FloatingPointBase () const
 Conversion operator to a native floating-point type.
 
bool operator!= (const Money &other) const
 Inequality Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
bool operator!= (const std::int16_t &value) const
 Inequality Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator!= (const std::int32_t &value) const
 Inequality Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator!= (const std::int64_t &value) const
 Inequality Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator!= (const std::int8_t &value) const
 Inequality Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
MajorUnit operator% (const MajorUnit &value) const
 Modulus operator performed upon /only/ the major units of the object’s current value.
 
Money operator% (const Money &) const =delete
 
Money operator* (const FloatingPointBase &value) const
 The multiplicative operator without any loss of precision. This only supports as many digits as minor digits.
 
Money operator* (const Money &) const =delete
 
Money operator* (const std::int16_t &value) const
 The multiplicative operator without any loss of precision.
 
Money operator* (const std::int32_t &value) const
 The multiplicative operator without any loss of precision.
 
Money operator* (const std::int64_t &value) const
 The multiplicative operator without any loss of precision.
 
Money operator* (const std::int8_t &value) const
 The multiplicative operator without any loss of precision.
 
Moneyoperator*= (const FloatingPointBase &value)
 Multiplicative assignment operator without any loss of precision. This only supports as many digits as minor digits.
 
Moneyoperator*= (const std::int16_t &value)
 Multiplicative assignment operator without any loss of precision.
 
Moneyoperator*= (const std::int32_t &value)
 Multiplicative assignment operator without any loss of precision.
 
Moneyoperator*= (const std::int64_t &value)
 Multiplicative assignment operator without any loss of precision.
 
Moneyoperator*= (const std::int8_t &value)
 Multiplicative assignment operator without any loss of precision.
 
Money operator+ (const Money &other) const
 The additive operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
Moneyoperator+= (const Money &other)
 Additive assignment operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
Money operator- () const
 Negation operator without any loss of precision during the conversion.
 
Money operator- (const Money &other) const
 The subtractive operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
Moneyoperator-= (const Money &other)
 Subtractive assignment operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
Money operator/ (const FloatingPointBase &value) const
 Division operator without any loss of precision. This only supports as many digits as minor digits.
 
FloatingPointBase operator/ (const Money &other) const
 The division operator for calculating ratios.
 
Money operator/ (const std::int16_t &value) const
 Division operator without any loss of precision.
 
Money operator/ (const std::int32_t &value) const
 Division operator without any loss of precision.
 
Money operator/ (const std::int64_t &value) const
 Division operator without any loss of precision.
 
Money operator/ (const std::int8_t &value) const
 Division operator without any loss of precision.
 
Moneyoperator/= (const FloatingPointBase &value)
 Division assignment operator without any loss of precision. This only supports as many digits as minor digits.
 
Moneyoperator/= (const std::int16_t &value)
 Division assignment operator without any loss of precision.
 
Moneyoperator/= (const std::int32_t &value)
 Division assignment operator without any loss of precision.
 
Moneyoperator/= (const std::int64_t &value)
 Division assignment operator without any loss of precision.
 
Moneyoperator/= (const std::int8_t &value)
 Division assignment operator without any loss of precision.
 
bool operator< (const Money &other) const
 Less-than Relational Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
bool operator< (const std::int16_t &value) const
 Less-than Relational Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator< (const std::int32_t &value) const
 Less-than Relational Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator< (const std::int64_t &value) const
 Less-than Relational Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator< (const std::int8_t &value) const
 Less-than Relational Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator<= (const Money &other) const
 Less-than-equal Relational Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
bool operator<= (const std::int16_t &value) const
 Less-than-equal Relational Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator<= (const std::int32_t &value) const
 Less-than-equal Relational Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator<= (const std::int64_t &value) const
 Less-than-equal Relational Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator<= (const std::int8_t &value) const
 Less-than-equal Relational Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
Moneyoperator= (const Money &other)
 The assignment Operator with a copy. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
bool operator== (const Money &other) const
 Equality Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
bool operator== (const std::int16_t &value) const
 Equality Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator== (const std::int32_t &value) const
 Equality Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator== (const std::int64_t &value) const
 Equality Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator== (const std::int8_t &value) const
 Equality Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator> (const Money &other) const
 Greater-than Relational Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
bool operator> (const std::int16_t &value) const
 Greater-than Relational Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator> (const std::int32_t &value) const
 Greater-than Relational Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator> (const std::int64_t &value) const
 Greater-than Relational Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator> (const std::int8_t &value) const
 Greater-than Relational Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator>= (const Money &other) const
 Greater-than-equal Relational Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.
 
bool operator>= (const std::int16_t &value) const
 Greater-than-equal Relational Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator>= (const std::int32_t &value) const
 Greater-than-equal Relational Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator>= (const std::int64_t &value) const
 Greater-than-equal Relational Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
bool operator>= (const std::int8_t &value) const
 Greater-than-equal Relational Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.
 
Money round (const RounderFunction &rounder, const std::uint8_t digits=defaultRoundingDigits) const
 Performs a rounding operation upon the monetary value.
 
MinorUnit subMinor () const
 Accessor to the sub-minor monetary value, e.g. only the U.S.A. fractional cents.
 
FloatingPointBase toFloatingPoint (const RounderFunction &rounder, const std::uint8_t digits=defaultRoundingDigits) const
 Converts the monetary value into a native floating-point type using a supplied rounding method.
 
void zeroOut ()
 Resets the monetary value to zero, without changing the currency.
 

Static Public Member Functions

static Money fromAmount (const MajorUnit amount, const Currency &code)
 Creates an instance from the entire representation of the monetary amount using the currency’s major unit, minor unit, and the sub-minor digits.
 
static MoneyParts maximum (const Currency &code) noexcept
 Calculates the largest monetary value that can be used for a given currency.
 
static MoneyParts minimum (const Currency &code) noexcept
 Calculates the smallest monetary value that can be used for a given currency.
 

Friends

PECUNIA_EXPORT Money math::absoluteValue (const Money &)
 
PECUNIA_EXPORT Money operator* (const FloatingPointBase &lhs, const Money &rhs)
 The multiplicative operator without any loss of precision. This only supports as many digits as minor digits.
 
PECUNIA_EXPORT Money operator* (const std::int16_t &lhs, const Money &rhs)
 The multiplicative operator without any loss of precision.
 
PECUNIA_EXPORT Money operator* (const std::int32_t &lhs, const Money &rhs)
 The multiplicative operator without any loss of precision.
 
PECUNIA_EXPORT Money operator* (const std::int64_t &lhs, const Money &rhs)
 The multiplicative operator without any loss of precision.
 
PECUNIA_EXPORT Money operator* (const std::int8_t &lhs, const Money &rhs)
 The multiplicative operator without any loss of precision.
 
PECUNIA_EXPORT std::ostream & operator<< (std::ostream &stream, const Money &m)
 Stream Insertion Operator. By default, the form will be in the locale’s monetary format with no spaces, the ISO code, and trailing the value, e.g. a U.S.A. locale with value of one dollar and twenty-three cents would appear as 1.23USD.
 
PECUNIA_EXPORT std::istream & operator>> (std::istream &stream, Money &m)
 Stream Extraction Operator. The monetary amount will be read in using the locale’s setting for reading in money. The currency code is required and must be in all upper-case letters.
 
PECUNIA_EXPORT void swap (Money &lhs, Money &rhs)
 Exchanges two monetary objects without any conversion operation performed.
 

Detailed Description

A representation of a country’s currency supporting basic arithmetic usage and guaranteeing all operations succeed without a loss of precision, overflow, or underflow.

Constructor & Destructor Documentation

◆ Money() [1/10]

pecunia::Money::Money ( )

Constructor for a fully formed object that initialises the stored amount to an unknown currency at zero.

◆ Money() [2/10]

pecunia::Money::Money ( const Currency & code)
explicit

Constructor for a fully formed object that initialises the stored amount to zero of a specific currency.

Parameters
codeThe currency code the amount represents.

◆ Money() [3/10]

pecunia::Money::Money ( const Minor & m)

Constructor for a fully formed object that initialises based on the currency’s minor value.

Parameters
mThe object from which to initialise the object.

◆ Money() [4/10]

pecunia::Money::Money ( const Currency & code,
const MajorUnit & major,
const MinorUnit & minor = 0u,
const MinorUnit & subMinor = 0 )

Constructor for setting an exact monetary value of a fully formed object for a currency that expects a minor value.

Precondition
The maximum minor value must fit within the MinorUnit.
Exceptions
OverflowErrorWhen the major unit is too large to be stored in a positive direction.
OverflowErrorWhen the major unit is too small to be stored in a negative direction.
OverflowErrorWhen the minor unit is too large to be stored.
OverflowErrorWhen the sub-minor unit is too large to be stored.
InvalidArgumentThrown if the `minor` value is provided while the currency does not support minor digits.
Parameters
codeThe currency code the amount represents.
majorThe amount of major currency to store, e.g. U.S.A. dollars.
minorThe amount of the minor currency to store, e.g. U.S.A. cents. For non-minor currencies, no minor unit will be set.
subMinorThe amount of the sub-minor currency to store, e.g. U.S.A. fractional cents.

◆ Money() [5/10]

pecunia::Money::Money ( const Currency & code,
const MajorUnit & major,
const std::optional< MinorUnit > & minor,
const MinorUnit & subMinor = 0 )

Constructor for setting an exact monetary value of a fully formed object for a currency that may support a minor value.

Precondition
The maximum minor value must fit within the MinorUnit.
Exceptions
OverflowErrorWhen the major unit is too large to be stored in a positive direction.
OverflowErrorWhen the major unit is too small to be stored in a negative direction.
OverflowErrorWhen the minor unit is too large to be stored.
OverflowErrorWhen the sub-minor unit is too large to be stored.
InvalidArgumentThrown if the `minor` value is provided while the currency does not support minor digits.
InvalidArgumentThrown if the `minor` value is /not/ provided while the currency does support minor digits.
Parameters
codeThe currency code the amount represents.
majorThe amount of major currency to store, e.g. U.S.A. dollars.
minorThe amount of the minor currency to store, e.g. U.S.A. cents.
subMinorThe amount of the sub-minor currency to store, e.g. U.S.A. fractional cents.

◆ Money() [6/10]

pecunia::Money::Money ( const MajorUnit & major,
const Currency & code )

Constructor for setting an exact monetary value of a fully formed object. This is most useful for the currencies that never have minor units.

Exceptions
OverflowErrorWhen the major unit is too large to be stored in a positive direction.
OverflowErrorWhen the major unit is too small to be stored in a negative direction.
Parameters
majorThe amount of major currency to store, e.g. Japan Yen.
codeThe currency code the amount represents.

◆ Money() [7/10]

pecunia::Money::Money ( const MajorUnit & major,
const MinorUnit & subMinor,
const Currency & code )

Constructor for setting an exact monetary value of a fully formed object. This is most useful for the currencies that never have minor units.

Exceptions
OverflowErrorWhen the major unit is too large to be stored in a positive direction.
OverflowErrorWhen the major unit is too small to be stored in a negative direction.
OverflowErrorWhen the sub-minor unit is too large to be stored.
Parameters
majorThe amount of major currency to store, e.g. Japan Yen.
subMinorThe amount of the sub-minor currency to store, e.g. Japan fractional Yen.
codeThe currency code the amount represents.

◆ Money() [8/10]

pecunia::Money::Money ( const FloatingPointRounderFunction & rounder,
const Currency & code,
const FloatingPointBase & value )

Constructor for setting a monetary value using the native floating-point type.

Note
Minor units in a floating-point value cannot be verified. They will always fit within the currency digits and precision specified, e.g. U.S.A. dollar value with sub-minor digits of 0 will store the value 1.555 as 1.55 when no rounder is supplied.
Exceptions
OverflowErrorWhen the major unit is too large to be stored in a positive direction.
OverflowErrorWhen the major unit is too small to be stored in a negative direction.
DomainErrorWhen the conversion results in the floating-point value dividing by zero.
UnderflowErrorWhen the floating-point value is too small to fit within the FloatingPoint.
OverflowErrorWhen the floating-point value is too large to fit within the FloatingPoint.
DomainErrorWhen the conversion results in the floating-point value not being valid.
Parameters
codeThe currency code the amount represents.
valueThe floating-point value to convert.
rounderThe method for rounding the number when converting the floating-point number.

◆ Money() [9/10]

pecunia::Money::Money ( const Money & )
default

◆ Money() [10/10]

pecunia::Money::Money ( Money && )
defaultnoexcept

◆ ~Money()

pecunia::Money::~Money ( )
default

Member Function Documentation

◆ amount()

const MajorUnit & pecunia::Money::amount ( ) const
nodiscardnoexcept

The entire representation of the monetary amount using the currency’s major unit, minor unit, and the sub-minor digits, in the form MajorMinorSub-minor.

◆ assign() [1/2]

Money & pecunia::Money::assign ( const Money & other)
noexcept

Assigns the value and currency from the provided object to the current instance.

Parameters
otherThe object whose value and currency will be assigned.
Postcondition
The current instance will have the same value and currency as the provided object.
Returns
The current instance after assignment.

◆ assign() [2/2]

Money & pecunia::Money::assign ( Money && other)
noexcept

Assigns the value and currency from the provided object to the current instance.

Parameters
otherThe object whose value and currency will be assigned.
Postcondition
The current instance will have the same value and currency as the provided object.
The other instance will have its internal properties reset or become invalid.
Returns
The current instance after assignment.

◆ clear()

void pecunia::Money::clear ( )
noexcept

Resets the object to its default state.

Postcondition
The object is reset to a default-constructed state.

◆ code()

const Currency & pecunia::Money::code ( ) const
nodiscardnoexcept

Accessor to the code the currency amount represents.

◆ fromAmount()

static Money pecunia::Money::fromAmount ( const MajorUnit amount,
const Currency & code )
static

Creates an instance from the entire representation of the monetary amount using the currency’s major unit, minor unit, and the sub-minor digits.

Exceptions
OverflowErrorWhen the major unit is too large to be stored in a positive direction.
OverflowErrorWhen the major unit is too small to be stored in a negative direction.
OverflowErrorWhen the minor unit is too large to be stored.
OverflowErrorWhen the sub-minor unit is too large to be stored.
Parameters
amountThe amount to be converted in the form MajorMinorSub-minor.
codeThe ISO-4217 code representing the currency.
Returns
An object that represents the given monetary amount in the specified currency.

◆ hasOnlyMinor()

bool pecunia::Money::hasOnlyMinor ( ) const
nodiscardnoexcept

Determines if the monetary amount consists of only minor units, i.e. only change.

Returns
Gives true when the amount is exclusively between negative one major unit and one major unit, false otherwise.

◆ major()

MajorUnit pecunia::Money::major ( ) const
nodiscard

Accessor to the major monetary value, e.g. only the U.S.A. dollars.

◆ maximum()

static MoneyParts pecunia::Money::maximum ( const Currency & code)
staticnodiscardnoexcept

Calculates the largest monetary value that can be used for a given currency.

Parameters
codeThe currency code to calculate the monetary value in.
Returns
The monetary components of the maximum value.

◆ minimum()

static MoneyParts pecunia::Money::minimum ( const Currency & code)
staticnodiscardnoexcept

Calculates the smallest monetary value that can be used for a given currency.

Parameters
codeThe currency code to calculate the monetary value in.
Returns
The monetary components of the minimum value.

◆ minorOnly()

std::optional< MinorUnit > pecunia::Money::minorOnly ( ) const
nodiscard

Accessor to the minor monetary value, e.g. the U.S.A. cents, truncating the fractional cents.

◆ minorWithSub()

MinorUnit pecunia::Money::minorWithSub ( ) const
nodiscard

Accessor to the minor and sub-minor monetary value, e.g. the U.S.A. cents and fractional cents.

◆ operator FloatingPointBase()

pecunia::Money::operator FloatingPointBase ( ) const
explicit

Conversion operator to a native floating-point type.

Exceptions
DomainErrorWhen the conversion results in the floating-point value dividing by zero.
UnderflowErrorWhen the floating-point value is too small to fit within the FloatingPoint.
OverflowErrorWhen the floating-point value is too large to fit within the FloatingPoint.
DomainErrorWhen the conversion results in the floating-point value not being valid.

◆ operator!=() [1/5]

bool pecunia::Money::operator!= ( const Money & other) const
nodiscard

Inequality Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Parameters
otherThe other object whose value is to be compared against.
Returns
A value of true with the current object is not equal to the supplied object, false else-wise.

◆ operator!=() [2/5]

bool pecunia::Money::operator!= ( const std::int16_t & value) const
nodiscard

Inequality Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is not equal to the supplied value, within the expected level of precision, false else-wise.

◆ operator!=() [3/5]

bool pecunia::Money::operator!= ( const std::int32_t & value) const
nodiscard

Inequality Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is not equal to the supplied value, within the expected level of precision, false else-wise.

◆ operator!=() [4/5]

bool pecunia::Money::operator!= ( const std::int64_t & value) const
nodiscard

Inequality Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is not equal to the supplied value, within the expected level of precision, false else-wise.

◆ operator!=() [5/5]

bool pecunia::Money::operator!= ( const std::int8_t & value) const
nodiscard

Inequality Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is not equal to the supplied value, within the expected level of precision, false else-wise.

◆ operator%() [1/2]

MajorUnit pecunia::Money::operator% ( const MajorUnit & value) const
nodiscard

Modulus operator performed upon /only/ the major units of the object’s current value.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
Parameters
valueThe additional value to perform a mod on the current object’s value.
Returns
The value of the modulus operation from the two values.

◆ operator%() [2/2]

Money pecunia::Money::operator% ( const Money & ) const
delete

◆ operator*() [1/6]

Money pecunia::Money::operator* ( const FloatingPointBase & value) const
nodiscard

The multiplicative operator without any loss of precision. This only supports as many digits as minor digits.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional value to multiply to the current object’s value.
Returns
A new object containing the product of the two values.

◆ operator*() [2/6]

Money pecunia::Money::operator* ( const Money & ) const
delete

◆ operator*() [3/6]

Money pecunia::Money::operator* ( const std::int16_t & value) const
nodiscard

The multiplicative operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe signed 16-bit integer value to multiply to the current object’s value.
Returns
A new object containing the product of the two values.

◆ operator*() [4/6]

Money pecunia::Money::operator* ( const std::int32_t & value) const
nodiscard

The multiplicative operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe signed 32-bit integer value to multiply to the current object’s value.
Returns
A new object containing the product of the two values.

◆ operator*() [5/6]

Money pecunia::Money::operator* ( const std::int64_t & value) const
nodiscard

The multiplicative operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe signed 64-bit integer value to multiply to the current object’s value.
Returns
A new object containing the product of the two values.

◆ operator*() [6/6]

Money pecunia::Money::operator* ( const std::int8_t & value) const
nodiscard

The multiplicative operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe signed 8-bit integer value to multiply to the current object’s value.
Returns
A new object containing the product of the two values.

◆ operator*=() [1/5]

Money & pecunia::Money::operator*= ( const FloatingPointBase & value)

Multiplicative assignment operator without any loss of precision. This only supports as many digits as minor digits.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional value to multiply to the current object.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the product of the two values.

◆ operator*=() [2/5]

Money & pecunia::Money::operator*= ( const std::int16_t & value)

Multiplicative assignment operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional signed 16-bit integer value to multiply to the current object.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the product of the two values.

◆ operator*=() [3/5]

Money & pecunia::Money::operator*= ( const std::int32_t & value)

Multiplicative assignment operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional signed 32-bit integer value to multiply to the current object.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the product of the two values.

◆ operator*=() [4/5]

Money & pecunia::Money::operator*= ( const std::int64_t & value)

Multiplicative assignment operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional signed 64-bit integer value to multiply to the current object.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the product of the two values.

◆ operator*=() [5/5]

Money & pecunia::Money::operator*= ( const std::int8_t & value)

Multiplicative assignment operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional signed 8-bit integer value to multiply to the current object.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the product of the two values.

◆ operator+()

Money pecunia::Money::operator+ ( const Money & other) const
nodiscard

The additive operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
otherThe additional value to add to the current object’s value.
Returns
A new object containing the summation of the two values.

◆ operator+=()

Money & pecunia::Money::operator+= ( const Money & other)

Additive assignment operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
otherThe additional value to add to the current object.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the summation of the two values.

◆ operator-() [1/2]

Money pecunia::Money::operator- ( ) const
nodiscard

Negation operator without any loss of precision during the conversion.

Returns
The negated value of the current object.

◆ operator-() [2/2]

Money pecunia::Money::operator- ( const Money & other) const
nodiscard

The subtractive operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
otherThe additional value to subtract from the current object’s value.
Returns
A new object containing the difference of the two values.

◆ operator-=()

Money & pecunia::Money::operator-= ( const Money & other)

Subtractive assignment operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
otherThe additional value to subtract from the current object.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the difference of the two values.

◆ operator/() [1/6]

Money pecunia::Money::operator/ ( const FloatingPointBase & value) const
nodiscard

Division operator without any loss of precision. This only supports as many digits as minor digits.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional value to divide by the current object’s value.
Returns
A new object containing the division of the two values.

◆ operator/() [2/6]

FloatingPointBase pecunia::Money::operator/ ( const Money & other) const
nodiscard

The division operator for calculating ratios.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
Parameters
otherThe value to divide by the current object’s value.
Returns
The result of the division between the two, a ratio.

◆ operator/() [3/6]

Money pecunia::Money::operator/ ( const std::int16_t & value) const
nodiscard

Division operator without any loss of precision.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional signed 16-bit integer value to divide by the current object’s value.
Returns
A new object containing the division of the two values.

◆ operator/() [4/6]

Money pecunia::Money::operator/ ( const std::int32_t & value) const
nodiscard

Division operator without any loss of precision.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional signed 32-bit integer value to divide by the current object’s value.
Returns
A new object containing the division of the two values.

◆ operator/() [5/6]

Money pecunia::Money::operator/ ( const std::int64_t & value) const
nodiscard

Division operator without any loss of precision.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional signed 64-bit integer value to divide by the current object’s value.
Returns
A new object containing the division of the two values.

◆ operator/() [6/6]

Money pecunia::Money::operator/ ( const std::int8_t & value) const
nodiscard

Division operator without any loss of precision.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional signed 8-bit integer value to divide by the current object’s value.
Returns
A new object containing the division of the two values.

◆ operator/=() [1/5]

Money & pecunia::Money::operator/= ( const FloatingPointBase & value)

Division assignment operator without any loss of precision. This only supports as many digits as minor digits.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe additional value to divide by the current object’s value.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the division of the two values.

◆ operator/=() [2/5]

Money & pecunia::Money::operator/= ( const std::int16_t & value)

Division assignment operator without any loss of precision.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe signed 16-bit integer additional value to divide by the current object’s value.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the division of the two values.

◆ operator/=() [3/5]

Money & pecunia::Money::operator/= ( const std::int32_t & value)

Division assignment operator without any loss of precision.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe signed 32-bit integer additional value to divide by the current object’s value.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the division of the two values.

◆ operator/=() [4/5]

Money & pecunia::Money::operator/= ( const std::int64_t & value)

Division assignment operator without any loss of precision.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe signed 64-bit integer additional value to divide by the current object’s value.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the division of the two values.

◆ operator/=() [5/5]

Money & pecunia::Money::operator/= ( const std::int8_t & value)

Division assignment operator without any loss of precision.

Exceptions
DomainErrorWhen the result of the operation would result in a division by zero.
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
valueThe signed 8-bit integer additional value to divide by the current object’s value.
Postcondition
The current object’s amount is changed using the mathematical operation. The current object’s currency does not change.
Returns
The current object containing the division of the two values.

◆ operator<() [1/5]

bool pecunia::Money::operator< ( const Money & other) const
nodiscard

Less-than Relational Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Parameters
otherThe other object whose value is to be compared against.
Returns
A value of true with the current object is less than the supplied object, false else-wise.

◆ operator<() [2/5]

bool pecunia::Money::operator< ( const std::int16_t & value) const
nodiscard

Less-than Relational Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is less than the supplied object, false else-wise.

◆ operator<() [3/5]

bool pecunia::Money::operator< ( const std::int32_t & value) const
nodiscard

Less-than Relational Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is less than the supplied object, false else-wise.

◆ operator<() [4/5]

bool pecunia::Money::operator< ( const std::int64_t & value) const
nodiscard

Less-than Relational Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is less than the supplied object, false else-wise.

◆ operator<() [5/5]

bool pecunia::Money::operator< ( const std::int8_t & value) const
nodiscard

Less-than Relational Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is less than the supplied object, false else-wise.

◆ operator<=() [1/5]

bool pecunia::Money::operator<= ( const Money & other) const
nodiscard

Less-than-equal Relational Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Parameters
otherThe other object whose value is to be compared against.
Returns
A value of true with the current object is less than or equal to the supplied object, false else-wise.

◆ operator<=() [2/5]

bool pecunia::Money::operator<= ( const std::int16_t & value) const
nodiscard

Less-than-equal Relational Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is less than or equal to the supplied object, false else-wise.

◆ operator<=() [3/5]

bool pecunia::Money::operator<= ( const std::int32_t & value) const
nodiscard

Less-than-equal Relational Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is less than or equal to the supplied object, false else-wise.

◆ operator<=() [4/5]

bool pecunia::Money::operator<= ( const std::int64_t & value) const
nodiscard

Less-than-equal Relational Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is less than or equal to the supplied object, false else-wise.

◆ operator<=() [5/5]

bool pecunia::Money::operator<= ( const std::int8_t & value) const
nodiscard

Less-than-equal Relational Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is less than or equal to the supplied object, false else-wise.

◆ operator=()

Money & pecunia::Money::operator= ( const Money & other)

The assignment Operator with a copy. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
OverflowErrorWhen the result of the operation would be too small to store.
Parameters
otherThe object whose amount is to be assigned into the current object.
Postcondition
The current object’s amount is changed to the supplied one. The original object’s currency does not change.
Returns
The current object with the new amount.

◆ operator==() [1/5]

bool pecunia::Money::operator== ( const Money & other) const
nodiscard

Equality Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Parameters
otherThe other object whose value is to be compared against.
Returns
A value of true with the current object is equal to the supplied object, false else-wise.

◆ operator==() [2/5]

bool pecunia::Money::operator== ( const std::int16_t & value) const
nodiscard

Equality Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is equal to the supplied value within the expected level of precision, false else-wise.

◆ operator==() [3/5]

bool pecunia::Money::operator== ( const std::int32_t & value) const
nodiscard

Equality Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is equal to the supplied value within the expected level of precision, false else-wise.

◆ operator==() [4/5]

bool pecunia::Money::operator== ( const std::int64_t & value) const
nodiscard

Equality Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is equal to the supplied value within the expected level of precision, false else-wise.

◆ operator==() [5/5]

bool pecunia::Money::operator== ( const std::int8_t & value) const
nodiscard

Equality Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is equal to the supplied value within the expected level of precision, false else-wise.

◆ operator>() [1/5]

bool pecunia::Money::operator> ( const Money & other) const
nodiscard

Greater-than Relational Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Parameters
otherThe other object whose value is to be compared against.
Returns
A value of true with the current object is greater than the supplied object, false else-wise.

◆ operator>() [2/5]

bool pecunia::Money::operator> ( const std::int16_t & value) const
nodiscard

Greater-than Relational Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is greater than the supplied object, false else-wise.

◆ operator>() [3/5]

bool pecunia::Money::operator> ( const std::int32_t & value) const
nodiscard

Greater-than Relational Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is greater than the supplied object, false else-wise.

◆ operator>() [4/5]

bool pecunia::Money::operator> ( const std::int64_t & value) const
nodiscard

Greater-than Relational Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is greater than the supplied object, false else-wise.

◆ operator>() [5/5]

bool pecunia::Money::operator> ( const std::int8_t & value) const
nodiscard

Greater-than Relational Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is greater than the supplied object, false else-wise.

◆ operator>=() [1/5]

bool pecunia::Money::operator>= ( const Money & other) const
nodiscard

Greater-than-equal Relational Operator. When the supplied monetary object is of a different currency, the amount is converted into the current object’s currency using the pecunia::converter function.

Parameters
otherThe other object whose value is to be compared against.
Returns
A value of true with the current object is greater than or equal to the supplied object, false else-wise.

◆ operator>=() [2/5]

bool pecunia::Money::operator>= ( const std::int16_t & value) const
nodiscard

Greater-than-equal Relational Operator for a 16-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is greater than or equal to the supplied object, false else-wise.

◆ operator>=() [3/5]

bool pecunia::Money::operator>= ( const std::int32_t & value) const
nodiscard

Greater-than-equal Relational Operator for a 32-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is greater than or equal to the supplied object, false else-wise.

◆ operator>=() [4/5]

bool pecunia::Money::operator>= ( const std::int64_t & value) const
nodiscard

Greater-than-equal Relational Operator for a 64-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is greater than or equal to the supplied object, false else-wise.

◆ operator>=() [5/5]

bool pecunia::Money::operator>= ( const std::int8_t & value) const
nodiscard

Greater-than-equal Relational Operator for an 8-bit signed integer. The supplied value is expressed in terms of the current object’s issued currency, in the form MajorMinorSub-minor.

Parameters
valueThe other object whose value is to be compared against.
Returns
A value of true with the current object is greater than or equal to the supplied object, false else-wise.

◆ round()

Money pecunia::Money::round ( const RounderFunction & rounder,
const std::uint8_t digits = defaultRoundingDigits ) const
nodiscard

Performs a rounding operation upon the monetary value.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
OverflowErrorWhen the result of the operation would be too small to store.
DomainErrorWhen the conversion results in the floating-point value dividing by zero.
UnderflowErrorWhen the floating-point value is too small to fit within the FloatingPoint.
OverflowErrorWhen the floating-point value is too large to fit within the FloatingPoint.
DomainErrorWhen the conversion results in the floating-point value not being valid.
Parameters
rounderThe rounding function to apply to the monetary value.
digitsThe number of digits after the major unit to round to.
Returns
A copy of the current object containing the rounded value.

◆ subMinor()

MinorUnit pecunia::Money::subMinor ( ) const
nodiscard

Accessor to the sub-minor monetary value, e.g. only the U.S.A. fractional cents.

◆ toFloatingPoint()

FloatingPointBase pecunia::Money::toFloatingPoint ( const RounderFunction & rounder,
const std::uint8_t digits = defaultRoundingDigits ) const
nodiscard

Converts the monetary value into a native floating-point type using a supplied rounding method.

Parameters
rounderThe rounding function to apply to the monetary value.
digitsThe number of digits after the major unit.
Exceptions
DomainErrorWhen the conversion results in the floating-point value dividing by zero.
UnderflowErrorWhen the floating-point value is too small to fit within the FloatingPoint.
OverflowErrorWhen the floating-point value is too large to fit within the FloatingPoint.
DomainErrorWhen the conversion results in the floating-point value not being valid.

◆ zeroOut()

void pecunia::Money::zeroOut ( )

Resets the monetary value to zero, without changing the currency.

Friends And Related Symbol Documentation

◆ math::absoluteValue

◆ operator* [1/5]

PECUNIA_EXPORT Money operator* ( const FloatingPointBase & lhs,
const Money & rhs )
friend

The multiplicative operator without any loss of precision. This only supports as many digits as minor digits.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
lhsThe amount by which to multiply the supplied object’s value.
rhsThe object that is to be multiplied.
Returns
A new object containing the product of the two values.

◆ operator* [2/5]

PECUNIA_EXPORT Money operator* ( const std::int16_t & lhs,
const Money & rhs )
friend

The multiplicative operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
lhsThe signed 16-bit integer amount by which to multiply the supplied object’s value.
rhsThe object that is to be multiplied.
Returns
A new object containing the product of the two values.

◆ operator* [3/5]

PECUNIA_EXPORT Money operator* ( const std::int32_t & lhs,
const Money & rhs )
friend

The multiplicative operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
lhsThe signed 32-bit integer amount by which to multiply the supplied object’s value.
rhsThe object that is to be multiplied.
Returns
A new object containing the product of the two values.

◆ operator* [4/5]

PECUNIA_EXPORT Money operator* ( const std::int64_t & lhs,
const Money & rhs )
friend

The multiplicative operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
lhsThe signed 64-bit integer amount by which to multiply the supplied object’s value.
rhsThe object that is to be multiplied.
Returns
A new object containing the product of the two values.

◆ operator* [5/5]

PECUNIA_EXPORT Money operator* ( const std::int8_t & lhs,
const Money & rhs )
friend

The multiplicative operator without any loss of precision.

Exceptions
OverflowErrorWhen the result of the operation would be too large to store.
UnderflowErrorWhen the result of the operation would be too small to store.
Parameters
lhsThe signed 8-bit integer amount by which to multiply the supplied object’s value.
rhsThe object that is to be multiplied.
Returns
A new object containing the product of the two values.

◆ operator<<

PECUNIA_EXPORT std::ostream & operator<< ( std::ostream & stream,
const Money & m )
friend

Stream Insertion Operator. By default, the form will be in the locale’s monetary format with no spaces, the ISO code, and trailing the value, e.g. a U.S.A. locale with value of one dollar and twenty-three cents would appear as 1.23USD.

Exceptions
RuntimeErrorWhen the stream fails to be written.
Parameters
streamThe destination source for the contents of the supplied money object.
mThe object whose values are placed into the destination source.
Returns
The modified source stream object filled with the contents of the money object.

◆ operator>>

PECUNIA_EXPORT std::istream & operator>> ( std::istream & stream,
Money & m )
friend

Stream Extraction Operator. The monetary amount will be read in using the locale’s setting for reading in money. The currency code is required and must be in all upper-case letters.

Precondition
The locale of the supplied stream must be set.
Exceptions
RuntimeErrorWhen the stream fails to be read.
InvalidArgumentWhen the currency is incorrectly formatted.
Parameters
streamThe extraction source for the contents of the supplied money object.
mThe object whose values are to be filled by the contents of the stream.
Returns
The modified source stream object emptied of a money entry.

◆ swap

PECUNIA_EXPORT void swap ( Money & lhs,
Money & rhs )
friend

Exchanges two monetary objects without any conversion operation performed.

Parameters
lhsThe object to swap to the right.
rhsThe object to swap to the left.