Pecunia 0.9.0-alpha.22
Library using the ISO-4217 currency standard & a fixed monetary unit size
|
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>
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. | |
Money & | assign (const Money &other) noexcept |
Assigns the value and currency from the provided object to the current instance. | |
Money & | assign (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 Currency & | code () 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. | |
Money & | operator*= (const FloatingPointBase &value) |
Multiplicative assignment operator without any loss of precision. This only supports as many digits as minor digits. | |
Money & | operator*= (const std::int16_t &value) |
Multiplicative assignment operator without any loss of precision. | |
Money & | operator*= (const std::int32_t &value) |
Multiplicative assignment operator without any loss of precision. | |
Money & | operator*= (const std::int64_t &value) |
Multiplicative assignment operator without any loss of precision. | |
Money & | operator*= (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. | |
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. | |
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. | |
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. | |
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. | |
Money & | operator/= (const FloatingPointBase &value) |
Division assignment operator without any loss of precision. This only supports as many digits as minor digits. | |
Money & | operator/= (const std::int16_t &value) |
Division assignment operator without any loss of precision. | |
Money & | operator/= (const std::int32_t &value) |
Division assignment operator without any loss of precision. | |
Money & | operator/= (const std::int64_t &value) |
Division assignment operator without any loss of precision. | |
Money & | operator/= (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. | |
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. | |
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. | |
A representation of a country’s currency supporting basic arithmetic usage and guaranteeing all operations succeed without a loss of precision, overflow, or underflow.
pecunia::Money::Money | ( | ) |
Constructor for a fully formed object that initialises the stored amount to an unknown currency at zero.
|
explicit |
Constructor for a fully formed object that initialises the stored amount to zero of a specific currency.
code | The currency code the amount represents. |
pecunia::Money::Money | ( | const Minor & | m | ) |
Constructor for a fully formed object that initialises based on the currency’s minor value.
m | The object from which to initialise the object. |
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.
OverflowError | When the major unit is too large to be stored in a positive direction. |
OverflowError | When the major unit is too small to be stored in a negative direction. |
OverflowError | When the minor unit is too large to be stored. |
OverflowError | When the sub-minor unit is too large to be stored. |
InvalidArgument | Thrown if the `minor` value is provided while the currency does not support minor digits. |
code | The currency code the amount represents. |
major | The amount of major currency to store, e.g. U.S.A. dollars. |
minor | The amount of the minor currency to store, e.g. U.S.A. cents. For non-minor currencies, no minor unit will be set. |
subMinor | The amount of the sub-minor currency to store, e.g. U.S.A. fractional cents. |
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.
OverflowError | When the major unit is too large to be stored in a positive direction. |
OverflowError | When the major unit is too small to be stored in a negative direction. |
OverflowError | When the minor unit is too large to be stored. |
OverflowError | When the sub-minor unit is too large to be stored. |
InvalidArgument | Thrown if the `minor` value is provided while the currency does not support minor digits. |
InvalidArgument | Thrown if the `minor` value is /not/ provided while the currency does support minor digits. |
code | The currency code the amount represents. |
major | The amount of major currency to store, e.g. U.S.A. dollars. |
minor | The amount of the minor currency to store, e.g. U.S.A. cents. |
subMinor | The amount of the sub-minor currency to store, e.g. U.S.A. fractional cents. |
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.
OverflowError | When the major unit is too large to be stored in a positive direction. |
OverflowError | When the major unit is too small to be stored in a negative direction. |
major | The amount of major currency to store, e.g. Japan Yen. |
code | The currency code the amount represents. |
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.
OverflowError | When the major unit is too large to be stored in a positive direction. |
OverflowError | When the major unit is too small to be stored in a negative direction. |
OverflowError | When the sub-minor unit is too large to be stored. |
major | The amount of major currency to store, e.g. Japan Yen. |
subMinor | The amount of the sub-minor currency to store, e.g. Japan fractional Yen. |
code | The currency code the amount represents. |
pecunia::Money::Money | ( | const FloatingPointRounderFunction & | rounder, |
const Currency & | code, | ||
const FloatingPointBase & | value ) |
Constructor for setting a monetary value using the native floating-point type.
OverflowError | When the major unit is too large to be stored in a positive direction. |
OverflowError | When the major unit is too small to be stored in a negative direction. |
DomainError | When the conversion results in the floating-point value dividing by zero. |
UnderflowError | When the floating-point value is too small to fit within the FloatingPoint. |
OverflowError | When the floating-point value is too large to fit within the FloatingPoint. |
DomainError | When the conversion results in the floating-point value not being valid. |
code | The currency code the amount represents. |
value | The floating-point value to convert. |
rounder | The method for rounding the number when converting the floating-point number. |
|
default |
|
defaultnoexcept |
|
default |
|
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.
Assigns the value and currency from the provided object to the current instance.
other | The object whose value and currency will be assigned. |
Assigns the value and currency from the provided object to the current instance.
other | The object whose value and currency will be assigned. |
other
instance will have its internal properties reset or become invalid.
|
noexcept |
Resets the object to its default state.
|
nodiscardnoexcept |
Accessor to the code the currency amount represents.
Creates an instance from the entire representation of the monetary amount using the currency’s major unit, minor unit, and the sub-minor digits.
OverflowError | When the major unit is too large to be stored in a positive direction. |
OverflowError | When the major unit is too small to be stored in a negative direction. |
OverflowError | When the minor unit is too large to be stored. |
OverflowError | When the sub-minor unit is too large to be stored. |
amount | The amount to be converted in the form MajorMinorSub-minor. |
code | The ISO-4217 code representing the currency. |
|
nodiscardnoexcept |
Determines if the monetary amount consists of only minor units, i.e. only change.
|
nodiscard |
Accessor to the major monetary value, e.g. only the U.S.A. dollars.
|
staticnodiscardnoexcept |
Calculates the largest monetary value that can be used for a given currency.
code | The currency code to calculate the monetary value in. |
|
staticnodiscardnoexcept |
Calculates the smallest monetary value that can be used for a given currency.
code | The currency code to calculate the monetary value in. |
|
nodiscard |
Accessor to the minor monetary value, e.g. the U.S.A. cents, truncating the fractional cents.
|
nodiscard |
Accessor to the minor and sub-minor monetary value, e.g. the U.S.A. cents and fractional cents.
|
explicit |
Conversion operator to a native floating-point type.
DomainError | When the conversion results in the floating-point value dividing by zero. |
UnderflowError | When the floating-point value is too small to fit within the FloatingPoint. |
OverflowError | When the floating-point value is too large to fit within the FloatingPoint. |
DomainError | When the conversion results in the floating-point value not being valid. |
|
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.
other | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
nodiscard |
Modulus operator performed upon /only/ the major units of the object’s current value.
DomainError | When the result of the operation would result in a division by zero. |
value | The additional value to perform a mod on the current object’s value. |
|
nodiscard |
The multiplicative operator without any loss of precision. This only supports as many digits as minor digits.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional value to multiply to the current object’s value. |
|
nodiscard |
The multiplicative operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The signed 16-bit integer value to multiply to the current object’s value. |
|
nodiscard |
The multiplicative operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The signed 32-bit integer value to multiply to the current object’s value. |
|
nodiscard |
The multiplicative operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The signed 64-bit integer value to multiply to the current object’s value. |
|
nodiscard |
The multiplicative operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The signed 8-bit integer value to multiply to the current object’s value. |
Money & pecunia::Money::operator*= | ( | const FloatingPointBase & | value | ) |
Multiplicative assignment operator without any loss of precision. This only supports as many digits as minor digits.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional value to multiply to the current object. |
Money & pecunia::Money::operator*= | ( | const std::int16_t & | value | ) |
Multiplicative assignment operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional signed 16-bit integer value to multiply to the current object. |
Money & pecunia::Money::operator*= | ( | const std::int32_t & | value | ) |
Multiplicative assignment operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional signed 32-bit integer value to multiply to the current object. |
Money & pecunia::Money::operator*= | ( | const std::int64_t & | value | ) |
Multiplicative assignment operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional signed 64-bit integer value to multiply to the current object. |
Money & pecunia::Money::operator*= | ( | const std::int8_t & | value | ) |
Multiplicative assignment operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional signed 8-bit integer value to multiply to the current object. |
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.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
other | The additional value to add to the current object’s value. |
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.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
other | The additional value to add to the current object. |
|
nodiscard |
Negation operator without any loss of precision during the conversion.
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.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
other | The additional value to subtract from the current object’s value. |
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.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
other | The additional value to subtract from the current object. |
|
nodiscard |
Division operator without any loss of precision. This only supports as many digits as minor digits.
DomainError | When the result of the operation would result in a division by zero. |
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional value to divide by the current object’s value. |
|
nodiscard |
The division operator for calculating ratios.
DomainError | When the result of the operation would result in a division by zero. |
other | The value to divide by the current object’s value. |
|
nodiscard |
Division operator without any loss of precision.
DomainError | When the result of the operation would result in a division by zero. |
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional signed 16-bit integer value to divide by the current object’s value. |
|
nodiscard |
Division operator without any loss of precision.
DomainError | When the result of the operation would result in a division by zero. |
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional signed 32-bit integer value to divide by the current object’s value. |
|
nodiscard |
Division operator without any loss of precision.
DomainError | When the result of the operation would result in a division by zero. |
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional signed 64-bit integer value to divide by the current object’s value. |
|
nodiscard |
Division operator without any loss of precision.
DomainError | When the result of the operation would result in a division by zero. |
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional signed 8-bit integer value to divide by the current object’s value. |
Money & pecunia::Money::operator/= | ( | const FloatingPointBase & | value | ) |
Division assignment operator without any loss of precision. This only supports as many digits as minor digits.
DomainError | When the result of the operation would result in a division by zero. |
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The additional value to divide by the current object’s value. |
Money & pecunia::Money::operator/= | ( | const std::int16_t & | value | ) |
Division assignment operator without any loss of precision.
DomainError | When the result of the operation would result in a division by zero. |
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The signed 16-bit integer additional value to divide by the current object’s value. |
Money & pecunia::Money::operator/= | ( | const std::int32_t & | value | ) |
Division assignment operator without any loss of precision.
DomainError | When the result of the operation would result in a division by zero. |
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The signed 32-bit integer additional value to divide by the current object’s value. |
Money & pecunia::Money::operator/= | ( | const std::int64_t & | value | ) |
Division assignment operator without any loss of precision.
DomainError | When the result of the operation would result in a division by zero. |
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The signed 64-bit integer additional value to divide by the current object’s value. |
Money & pecunia::Money::operator/= | ( | const std::int8_t & | value | ) |
Division assignment operator without any loss of precision.
DomainError | When the result of the operation would result in a division by zero. |
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
value | The signed 8-bit integer additional value to divide by the current object’s value. |
|
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.
other | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
other | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
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.
OverflowError | When the result of the operation would be too large to store. |
OverflowError | When the result of the operation would be too small to store. |
other | The object whose amount is to be assigned into the current object. |
|
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.
other | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
other | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
other | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
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.
value | The other object whose value is to be compared against. |
|
nodiscard |
Performs a rounding operation upon the monetary value.
OverflowError | When the result of the operation would be too large to store. |
OverflowError | When the result of the operation would be too small to store. |
DomainError | When the conversion results in the floating-point value dividing by zero. |
UnderflowError | When the floating-point value is too small to fit within the FloatingPoint. |
OverflowError | When the floating-point value is too large to fit within the FloatingPoint. |
DomainError | When the conversion results in the floating-point value not being valid. |
rounder | The rounding function to apply to the monetary value. |
digits | The number of digits after the major unit to round to. |
|
nodiscard |
Accessor to the sub-minor monetary value, e.g. only the U.S.A. fractional cents.
|
nodiscard |
Converts the monetary value into a native floating-point type using a supplied rounding method.
rounder | The rounding function to apply to the monetary value. |
digits | The number of digits after the major unit. |
DomainError | When the conversion results in the floating-point value dividing by zero. |
UnderflowError | When the floating-point value is too small to fit within the FloatingPoint. |
OverflowError | When the floating-point value is too large to fit within the FloatingPoint. |
DomainError | When the conversion results in the floating-point value not being valid. |
void pecunia::Money::zeroOut | ( | ) |
Resets the monetary value to zero, without changing the currency.
|
friend |
|
friend |
The multiplicative operator without any loss of precision. This only supports as many digits as minor digits.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
lhs | The amount by which to multiply the supplied object’s value. |
rhs | The object that is to be multiplied. |
|
friend |
The multiplicative operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
lhs | The signed 16-bit integer amount by which to multiply the supplied object’s value. |
rhs | The object that is to be multiplied. |
|
friend |
The multiplicative operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
lhs | The signed 32-bit integer amount by which to multiply the supplied object’s value. |
rhs | The object that is to be multiplied. |
|
friend |
The multiplicative operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
lhs | The signed 64-bit integer amount by which to multiply the supplied object’s value. |
rhs | The object that is to be multiplied. |
|
friend |
The multiplicative operator without any loss of precision.
OverflowError | When the result of the operation would be too large to store. |
UnderflowError | When the result of the operation would be too small to store. |
lhs | The signed 8-bit integer amount by which to multiply the supplied object’s value. |
rhs | The object that is to be multiplied. |
|
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.
RuntimeError | When the stream fails to be written. |
stream | The destination source for the contents of the supplied money object. |
m | The object whose values are placed into the destination source. |
|
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.
RuntimeError | When the stream fails to be read. |
InvalidArgument | When the currency is incorrectly formatted. |
stream | The extraction source for the contents of the supplied money object. |
m | The object whose values are to be filled by the contents of the stream. |
|
friend |
Exchanges two monetary objects without any conversion operation performed.
lhs | The object to swap to the right. |
rhs | The object to swap to the left. |