sparrow 1.0.0
Loading...
Searching...
No Matches
sparrow::decimal_reference< L > Class Template Reference

#include <decimal_reference.hpp>

Public Types

using self_type = decimal_reference<L>
 
using value_type = typename L::inner_value_type
 
using reference = typename L::inner_reference
 
using const_reference = typename L::inner_const_reference
 
using size_type = typename L::size_type
 
using difference_type = std::ptrdiff_t
 

Public Member Functions

constexpr decimal_reference (L *layout, size_type index) noexcept
 Constructs a decimal reference for the given layout and index.
 
constexpr decimal_reference (const decimal_reference &)=default
 
constexpr decimal_reference (decimal_reference &&) noexcept=default
 
constexpr self_typeoperator= (self_type &&rhs) noexcept
 Move assignment from another decimal reference.
 
constexpr self_typeoperator= (const self_type &rhs)
 Copy assignment from another decimal reference.
 
constexpr self_typeoperator= (value_type &&rhs)
 Move assignment from a decimal value.
 
constexpr self_typeoperator= (const value_type &rhs)
 Copy assignment from a decimal value.
 
constexpr operator float () const
 Conversion to float.
 
constexpr operator double () const
 Conversion to double.
 
constexpr operator long double () const
 Conversion to long double.
 
 operator std::string () const
 Conversion to string representation.
 
constexpr bool operator== (const value_type &rhs) const
 Equality comparison with decimal value.
 
constexpr auto operator<=> (const value_type &rhs) const
 Three-way comparison with decimal value.
 
constexpr const_reference value () const
 Gets the referenced decimal value.
 
constexpr value_type::integer_type storage () const
 Gets the raw storage value of the decimal.
 
constexpr int scale () const
 Gets the scale of the decimal.
 

Detailed Description

template<class L>
class sparrow::decimal_reference< L >
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/decimal_reference.hpp.

Definition at line 59 of file decimal_reference.hpp.

Member Typedef Documentation

◆ const_reference

template<class L>
using sparrow::decimal_reference< L >::const_reference = typename L::inner_const_reference

◆ difference_type

template<class L>
using sparrow::decimal_reference< L >::difference_type = std::ptrdiff_t

Definition at line 68 of file decimal_reference.hpp.

◆ reference

template<class L>
using sparrow::decimal_reference< L >::reference = typename L::inner_reference

◆ self_type

◆ size_type

template<class L>
using sparrow::decimal_reference< L >::size_type = typename L::size_type

◆ value_type

template<class L>
using sparrow::decimal_reference< L >::value_type = typename L::inner_value_type

Constructor & Destructor Documentation

◆ decimal_reference() [1/3]

template<typename L>
sparrow::decimal_reference< L >::decimal_reference ( L * layout,
size_type index )
constexprnoexcept

Constructs a decimal reference for the given layout and index.

Parameters
layoutPointer to the layout containing the decimal data
indexIndex of the decimal element in the layout
Precondition
layout must not be nullptr
index must be valid within the layout bounds
Postcondition
Reference is bound to the specified element
Layout pointer and index are stored for future operations
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/decimal_reference.hpp.

Definition at line 260 of file decimal_reference.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decimal_reference() [2/3]

template<class L>
sparrow::decimal_reference< L >::decimal_reference ( const decimal_reference< L > & )
constexprdefault

◆ decimal_reference() [3/3]

template<class L>
sparrow::decimal_reference< L >::decimal_reference ( decimal_reference< L > && )
constexprdefaultnoexcept

Member Function Documentation

◆ operator double()

template<typename L>
requires (!is_int_placeholder_v<typename value_type::integer_type>)
sparrow::decimal_reference< L >::operator double ( ) const
explicitconstexpr

Conversion to double.

Converts the referenced decimal value to a double-precision floating-point representation. Provides better precision than float conversion.

Returns
Double approximation of the decimal value
Precondition
value_type::integer_type must not be a placeholder type
Postcondition
Return value approximates the decimal's mathematical value
Better precision than float conversion

Definition at line 332 of file decimal_reference.hpp.

Here is the call graph for this function:

◆ operator float()

template<typename L>
requires (!is_int_placeholder_v<typename value_type::integer_type>)
sparrow::decimal_reference< L >::operator float ( ) const
explicitconstexpr

Conversion to float.

Converts the referenced decimal value to a floating-point representation. May lose precision for large values or high-precision decimals.

Returns
Float approximation of the decimal value
Precondition
value_type::integer_type must not be a placeholder type
Postcondition
Return value approximates the decimal's mathematical value
May lose precision due to float's limited precision

Definition at line 325 of file decimal_reference.hpp.

Here is the call graph for this function:

◆ operator long double()

template<typename L>
requires (!is_int_placeholder_v<typename value_type::integer_type>)
sparrow::decimal_reference< L >::operator long double ( ) const
explicitconstexpr

Conversion to long double.

Converts the referenced decimal value to a long double floating-point representation. Provides the highest precision among floating-point conversions.

Returns
Long double approximation of the decimal value
Precondition
value_type::integer_type must not be a placeholder type
Postcondition
Return value approximates the decimal's mathematical value
Highest precision among floating-point conversions

Definition at line 339 of file decimal_reference.hpp.

Here is the call graph for this function:

◆ operator std::string()

template<class L>
sparrow::decimal_reference< L >::operator std::string ( ) const
explicitnodiscard

Conversion to string representation.

Converts the referenced decimal value to its human-readable string representation with proper decimal point placement.

Returns
String representation of the decimal value
Precondition
value_type::integer_type must not be a placeholder type
Postcondition
Returns exact string representation of the decimal
Format matches decimal's string conversion rules

◆ operator<=>()

template<typename L>
auto sparrow::decimal_reference< L >::operator<=> ( const value_type & rhs) const
constexpr

Three-way comparison with decimal value.

Parameters
rhsDecimal value to compare with
Returns
Ordering result of the comparison
Postcondition
Comparison includes both storage value and scale
Uses decimal's comparison operator semantics
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/decimal_reference.hpp.

Definition at line 301 of file decimal_reference.hpp.

Here is the call graph for this function:

◆ operator=() [1/4]

template<typename L>
auto sparrow::decimal_reference< L >::operator= ( const self_type & rhs)
constexpr

Copy assignment from another decimal reference.

Parameters
rhsSource decimal reference to copy from
Returns
Reference to this object
Precondition
rhs must be valid (pointing to valid layout and index)
Postcondition
This reference's target is assigned the value from rhs
rhs remains unchanged

Definition at line 288 of file decimal_reference.hpp.

Here is the call graph for this function:

◆ operator=() [2/4]

template<typename L>
auto sparrow::decimal_reference< L >::operator= ( const value_type & rhs)
constexpr

Copy assignment from a decimal value.

Parameters
rhsDecimal value to copy assign
Returns
Reference to this object
Precondition
Layout must remain valid during assignment
Index must be within layout bounds
Postcondition
Underlying layout element is assigned the copied value
rhs remains unchanged

Definition at line 274 of file decimal_reference.hpp.

◆ operator=() [3/4]

template<typename L>
auto sparrow::decimal_reference< L >::operator= ( self_type && rhs)
constexprnoexcept

Move assignment from another decimal reference.

Parameters
rhsSource decimal reference to move from
Returns
Reference to this object
Precondition
rhs must be valid (pointing to valid layout and index)
Postcondition
This reference's target is assigned the value from rhs
rhs remains valid but may be in unspecified state
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/decimal_reference.hpp.

Definition at line 281 of file decimal_reference.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [4/4]

template<typename L>
auto sparrow::decimal_reference< L >::operator= ( value_type && rhs)
constexpr

Move assignment from a decimal value.

Parameters
rhsDecimal value to move assign
Returns
Reference to this object
Precondition
Layout must remain valid during assignment
Index must be within layout bounds
Postcondition
Underlying layout element is assigned the moved value
rhs is moved from and may be in unspecified state

Definition at line 267 of file decimal_reference.hpp.

◆ operator==()

template<typename L>
bool sparrow::decimal_reference< L >::operator== ( const value_type & rhs) const
constexpr

Equality comparison with decimal value.

Parameters
rhsDecimal value to compare with
Returns
true if the referenced decimal equals rhs, false otherwise
Postcondition
Comparison includes both storage value and scale
Uses decimal's equality operator semantics
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/decimal_reference.hpp.

Definition at line 295 of file decimal_reference.hpp.

Here is the call graph for this function:

◆ scale()

template<typename L>
int sparrow::decimal_reference< L >::scale ( ) const
nodiscardconstexpr

Gets the scale of the decimal.

Returns
The scale factor of the decimal
Postcondition
Returns the decimal scale (power of 10 divisor)
Equivalent to value().scale()
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/decimal_reference.hpp.

Definition at line 319 of file decimal_reference.hpp.

Here is the call graph for this function:

◆ storage()

template<typename L>
auto sparrow::decimal_reference< L >::storage ( ) const
nodiscardconstexpr

Gets the raw storage value of the decimal.

Returns
The integer storage value (coefficient) of the decimal
Postcondition
Returns the raw integer value before scale application
Equivalent to value().storage()
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/decimal_reference.hpp.

Definition at line 313 of file decimal_reference.hpp.

Here is the call graph for this function:

◆ value()

template<typename L>
auto sparrow::decimal_reference< L >::value ( ) const
nodiscardconstexpr

Gets the referenced decimal value.

Returns
Const reference to the decimal value in the layout
Precondition
Layout and index must still be valid
Postcondition
Returns reference to the actual decimal stored in layout
Reference remains valid while layout is unchanged
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/decimal_reference.hpp.

Definition at line 307 of file decimal_reference.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: