[#FeePerUnit]
= FeePerUnit
:mrdocs:

Tagged wrapper around FeeFrac to avoid unit confusion&period;

== Synopsis

Declared in `&lt;util&sol;feefrac&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename Tag&gt;
struct FeePerUnit
    : xref:FeeFrac.adoc[FeeFrac]
----

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:FeeFrac.adoc[FeeFrac]`
| Data structure storing a fee and size&period;
|===

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:FeeFrac/operator_assign.adoc[`operator&equals;`] 
| Copy&hyphen;assign the fee and size from another FeeFrac&period;
| xref:FeeFrac/EvaluateFee.adoc[`EvaluateFee`] 
| Compute the fee for a given size `at&lowbar;size` using this object&apos;s feerate&period;
| xref:FeeFrac/EvaluateFeeDown.adoc[`EvaluateFeeDown`] 
| Compute the fee for a given size `at&lowbar;size` using this object&apos;s feerate, rounding down&period;
| xref:FeeFrac/EvaluateFeeUp.adoc[`EvaluateFeeUp`] 
| Compute the fee for a given size `at&lowbar;size` using this object&apos;s feerate, rounding up&period;
| xref:FeeFrac/IsEmpty.adoc[`IsEmpty`] 
| Check if this is empty (size and fee are 0)&period;
| xref:FeeFrac/operator_plus_eq.adoc[`operator&plus;&equals;`] 
| Add fee and size of another FeeFrac to this one&period;
| xref:FeeFrac/operator_minus_eq.adoc[`operator&hyphen;&equals;`] 
| Subtract fee and size of another FeeFrac from this one&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:FeeFrac/Div.adoc[`Div`] 
| Helper function for 96&sol;32 signed division, rounding towards negative infinity (if round&lowbar;down), or towards positive infinity (if !round&lowbar;down)&period; This is a version relying on &lowbar;&lowbar;int128&period;
| xref:FeeFrac/DivFallback.adoc[`DivFallback`] 
| Helper function for 96&sol;32 signed division, rounding towards negative infinity (if round&lowbar;down) or positive infinity (if !round&lowbar;down)&period; This is a fallback version, separate so that it can be tested on platforms where it isn&apos;t actually needed&period;
| xref:FeePerUnit/FromFeeFrac.adoc[`FromFeeFrac`] 
| Convert a FeeFrac to a FeePerUnit&period;
| xref:FeeFrac/Mul.adoc[`Mul`] 
| Helper function for 32&ast;64 signed multiplication, returning an unspecified but totally ordered type&period; This is a version relying on &lowbar;&lowbar;int128&period;
| xref:FeeFrac/MulFallback.adoc[`MulFallback`] 
| Helper function for 32&ast;64 signed multiplication, returning an unspecified but totally ordered type&period; This is a fallback version, separate so it can be tested on platforms where it isn&apos;t actually needed&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:FeeFrac/fee.adoc[`fee`] 
| The fee, in satoshis&period;
| xref:FeeFrac/size.adoc[`size`] 
| The size, in the unit chosen by the caller (for example vbytes or weight units)&period;
|===


== Using Declarations

[cols="1,4"]
|===
| Name| Description
| xref:FeePerUnit/2constructor.adoc[`FeePerUnit`] 
| Inherit the FeeFrac constructors&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:operator_plus-0f3.adoc[`operator&plus;`]
| Sum fee and size&period;
| xref:operator_minus-0b.adoc[`operator&hyphen;`]
| Subtract both fee and size&period;
| xref:operator_eq-03b.adoc[`operator&equals;&equals;`]
| Check if two FeeFrac objects are equal (both same fee and same size)&period;
| xref:swap-02.adoc[`swap`]
| Swap two FeeFracs&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
