UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FNumericUnit< NumericType > Struct Template Reference

#include <UnitConversion.h>

Public Member Functions

 FNumericUnit ()
 
 FNumericUnit (const NumericType &InValue, EUnit InUnits=EUnit::Unspecified)
 
 FNumericUnit (const FNumericUnit &Other)
 
FNumericUnitoperator= (const FNumericUnit &Other)
 
template<typename OtherType >
 FNumericUnit (const FNumericUnit< OtherType > &Other)
 
template<typename OtherType >
FNumericUnitoperator= (const FNumericUnit< OtherType > &Other)
 
TOptional< FNumericUnit< NumericType > > ConvertTo (EUnit ToUnits) const
 
FNumericUnit< NumericType > QuantizeUnitsToBestFit () const
 
template<typename OtherType >
FNumericUnit< NumericType > & operator= (const FNumericUnit< OtherType > &Other)
 

Static Public Member Functions

static TValueOrError< FNumericUnit< NumericType >, FTextTryParseExpression (const TCHAR *InExpression, EUnit InDefaultUnit, const FNumericUnit< NumericType > &InExistingValue)
 
static TOptional< FNumericUnit< NumericType > > TryParseString (const TCHAR *InSource)
 

Public Attributes

NumericType Value
 
const EUnit Units
 

Friends

template<typename OtherType >
bool operator== (const FNumericUnit< NumericType > &LHS, const FNumericUnit< OtherType > &RHS)
 
template<typename OtherType >
bool operator!= (const FNumericUnit< NumericType > &LHS, const FNumericUnit< OtherType > &RHS)
 

Detailed Description

template<typename NumericType>
struct FNumericUnit< NumericType >

FNumericUnit is a numeric type that wraps the templated type, whilst a specified unit. It handles conversion to/from related units automatically. The units are considered not to contribute to the type's state, and as such should be considered immutable once set.

Constructor & Destructor Documentation

◆ FNumericUnit() [1/4]

template<typename NumericType >
FNumericUnit< NumericType >::FNumericUnit ( )

Constructors

◆ FNumericUnit() [2/4]

template<typename NumericType >
FNumericUnit< NumericType >::FNumericUnit ( const NumericType &  InValue,
EUnit  InUnits = EUnit::Unspecified 
)

◆ FNumericUnit() [3/4]

template<typename NumericType >
FNumericUnit< NumericType >::FNumericUnit ( const FNumericUnit< NumericType > &  Other)

Copy construction/assignment from the same type

◆ FNumericUnit() [4/4]

template<typename NumericType >
template<typename OtherType >
FNumericUnit< NumericType >::FNumericUnit ( const FNumericUnit< OtherType > &  Other)

Templated Copy construction/assignment from differing numeric types. Relies on implicit conversion of the two numeric types.

Member Function Documentation

◆ ConvertTo()

template<typename NumericType >
TOptional< FNumericUnit< NumericType > > FNumericUnit< NumericType >::ConvertTo ( EUnit  ToUnits) const

Convert this quantity to a different unit

◆ operator=() [1/3]

template<typename NumericType >
FNumericUnit< NumericType > & FNumericUnit< NumericType >::operator= ( const FNumericUnit< NumericType > &  Other)

◆ operator=() [2/3]

template<typename NumericType >
template<typename OtherType >
FNumericUnit & FNumericUnit< NumericType >::operator= ( const FNumericUnit< OtherType > &  Other)

◆ operator=() [3/3]

template<typename NumericType >
template<typename OtherType >
FNumericUnit< NumericType > & FNumericUnit< NumericType >::operator= ( const FNumericUnit< OtherType > &  Other)

◆ QuantizeUnitsToBestFit()

template<typename NumericType >
FNumericUnit< NumericType > FNumericUnit< NumericType >::QuantizeUnitsToBestFit ( ) const

Quantizes this number to the most appropriate unit for user friendly presentation (e.g. 1000m returns 1km).

◆ TryParseExpression()

template<typename NumericType >
TValueOrError< FNumericUnit< NumericType >, FText > FNumericUnit< NumericType >::TryParseExpression ( const TCHAR InExpression,
EUnit  InDefaultUnit,
const FNumericUnit< NumericType > &  InExistingValue 
)
static

Try and parse an expression into a numeric unit

◆ TryParseString()

template<typename NumericType >
TOptional< FNumericUnit< NumericType > > FNumericUnit< NumericType >::TryParseString ( const TCHAR InSource)
static

Parse a numeric unit from a string

Friends And Related Symbol Documentation

◆ operator!=

template<typename NumericType >
template<typename OtherType >
bool operator!= ( const FNumericUnit< NumericType > &  LHS,
const FNumericUnit< OtherType > &  RHS 
)
friend

◆ operator==

template<typename NumericType >
template<typename OtherType >
bool operator== ( const FNumericUnit< NumericType > &  LHS,
const FNumericUnit< OtherType > &  RHS 
)
friend

Global arithmetic operators for number types. Deals with conversion from related units correctly. Note must be inlined for hidden friend optimization to work

Member Data Documentation

◆ Units

template<typename NumericType >
const EUnit FNumericUnit< NumericType >::Units

The associated units for the value. Can never change once set to anything other than EUnit::Unspecified.

◆ Value

template<typename NumericType >
NumericType FNumericUnit< NumericType >::Value

The numeric (scalar) value


The documentation for this struct was generated from the following files: