ORIGINAL
|
Represents a time duration with nanosecond precision. More...
#include <zeit.h>
Public Member Functions | |
duration (time_val_type val=0, unit unit=MILLISECOND) | |
Constructs a duration with given value and unit. | |
duration (const duration &other)=default | |
Default copy constructor. | |
duration & | operator= (const duration &other)=default |
Default copy assignment. | |
duration (duration &&other) noexcept | |
Move constructor. | |
duration & | operator= (duration &&other) noexcept |
Move assignment. | |
time_val_type | value (unit unit=MILLISECOND) const |
Gets the duration value in specified units. | |
integer | compareTo (const duration &other) const override |
Compares this duration to another. | |
u_integer | toHash () const noexcept override |
Computes hash value for this duration. | |
std::string | className () const override |
Gets the class name. | |
std::string | toString (bool enter) const override |
Converts duration to string representation. | |
duration & | operator++ () |
Prefix increment (adds 1 nanosecond) | |
duration | operator++ (int postfix) |
Postfix increment (adds 1 nanosecond) | |
duration & | operator-- () |
Prefix decrement (subtracts 1 nanosecond) | |
duration | operator-- (int postfix) |
Postfix decrement (subtracts 1 nanosecond) | |
duration & | operator+= (const duration &other) |
Adds another duration to this one. | |
duration & | operator-= (const duration &other) |
Subtracts another duration from this one. | |
duration & | operator*= (time_val_type factor) |
Multiplies duration by a factor. | |
duration & | operator/= (time_val_type factor) |
Divides duration by a factor. | |
duration & | operator/= (const duration &other) |
Divides duration by another duration. | |
floating | div (time_val_type factor, unit unit=MILLISECOND) const |
Floating-point division by a factor. | |
floating | div (const duration &other) const |
Floating-point division by another duration. | |
![]() | |
virtual integer | compareTo (const duration &other) const=0 |
Compares the current object with another of the same type. | |
bool | operator== (const duration &other) const |
Checks if the current object is equal to another. | |
bool | operator!= (const duration &other) const |
Checks if the current object is not equal to another. | |
bool | operator< (const duration &other) const |
Checks if the current object is less than another. | |
bool | operator> (const duration &other) const |
Checks if the current object is greater than another. | |
bool | operator<= (const duration &other) const |
Checks if the current object is less than or equal to another. | |
bool | operator>= (const duration &other) const |
Checks if the current object is greater than or equal to another. | |
virtual | ~comparable ()=default |
Virtual destructor for proper cleanup of derived objects. | |
![]() | |
virtual bool | equals (const duration &other) const noexcept |
Compares two objects for equality. | |
virtual | ~hashable ()=0 |
Virtual destructor. | |
![]() | |
operator std::string () const | |
Explicit conversion to std::string. | |
operator const char * () const | |
Explicit conversion to C-style string. | |
const char * | toCString (bool enter) const |
Direct C-string access with formatting control. | |
template<typename TYPE > | |
auto | formatString (const TYPE &t) -> std::string |
template<typename TYPE > | |
auto | formatCString (const TYPE &t) -> const char * |
template<typename TYPE > | |
auto | formatEnum (const TYPE &t) -> std::string |
template<typename TYPE > | |
auto | formatString (TYPE *const &ptr) -> std::string |
Static Public Attributes | |
static const duration | ZERO = duration{} |
Zero duration constant. | |
Friends | |
class | point |
duration | operator- (const duration &d) |
Negation operator. | |
duration | operator+ (const duration &lhs, const duration &rhs) |
Addition operator. | |
duration | operator- (const duration &lhs, const duration &rhs) |
Subtraction operator. | |
duration | operator* (const duration &d, time_val_type factor) |
Multiplication operator (duration * factor) | |
duration | operator* (time_val_type factor, const duration &d) |
Multiplication operator (factor * duration) | |
duration | operator/ (const duration &d, time_val_type factor) |
Division operator (duration / factor) | |
duration | operator/ (const duration &lhs, const duration &rhs) |
Division operator (duration / duration) | |
duration | abs (const duration &d) |
Absolute value of duration. | |
Additional Inherited Members | |
![]() | |
template<typename TYPE > | |
static std::string | formatString (const TYPE &t) |
Universal value-to-string conversion with type-specific formatting. | |
template<Printable TYPE> | |
static std::string | formatString (const TYPE &t) |
Specialization for types deriving from printable. | |
template<EnumType TYPE> | |
static std::string | formatString (const TYPE &t) |
Specialization for enum types with type-safe formatting. | |
template<typename TYPE > | |
static std::string | formatString (TYPE *const &ptr) |
Pointer-specific formatting with null safety. | |
template<typename TYPE > | |
static const char * | formatCString (const TYPE &t) |
C-string cache for temporary usage with static storage. | |
template<typename TYPE > | |
static std::string | formatEnum (const TYPE &t) |
Enum formatting utility with underlying value extraction. | |
template<> | |
auto | formatString (const char &t) -> std::string |
template<> | |
auto | formatString (const bool &t) -> std::string |
template<> | |
auto | formatString (const char *const &ptr) -> std::string |
Represents a time duration with nanosecond precision.
Supports arithmetic operations and conversions between different time units.
|
inlineexplicit |
Constructs a duration with given value and unit.
val | Time value |
unit | Unit of time (default: MILLISECOND) |
|
inlinenoexcept |
Move constructor.
other | Duration to move from |
|
inlineoverridevirtual |
|
inlineoverride |
Compares this duration to another.
other | Duration to compare with |
|
inline |
Floating-point division by another duration.
other | Duration to divide by |
|
inline |
Floating-point division by a factor.
factor | Division factor |
unit | Unit for factor (default: MILLISECOND) |
|
inline |
Multiplies duration by a factor.
factor | Multiplication factor |
|
inline |
Prefix increment (adds 1 nanosecond)
|
inline |
Postfix increment (adds 1 nanosecond)
postfix | Dummy parameter for postfix |
|
inline |
Adds another duration to this one.
other | Duration to add |
|
inline |
Prefix decrement (subtracts 1 nanosecond)
|
inline |
Postfix decrement (subtracts 1 nanosecond)
postfix | Dummy parameter for postfix |
|
inline |
Subtracts another duration from this one.
other | Duration to subtract |
|
inline |
Divides duration by another duration.
other | Duration to divide by |
|
inline |
Divides duration by a factor.
factor | Division factor |
|
inlinenoexcept |
Move assignment.
other | Duration to move from |
|
inlineoverridevirtualnoexcept |
Computes hash value for this duration.
Reimplemented from original::hashable< duration >.
|
inlineoverridevirtual |
Converts duration to string representation.
enter | Whether to include newline |
Reimplemented from original::printable.
|
inline |
Gets the duration value in specified units.
unit | Unit to return value in (default: MILLISECOND) |
Absolute value of duration.
d | Duration to get absolute value of |
|
friend |
Multiplication operator (duration * factor)
d | Duration to multiply |
factor | Multiplication factor |
|
friend |
Multiplication operator (factor * duration)
factor | Multiplication factor |
d | Duration to multiply |
Addition operator.
lhs | Left operand |
rhs | Right operand |
Negation operator.
d | Duration to negate |
Subtraction operator.
lhs | Left operand |
rhs | Right operand |
|
friend |
Division operator (duration / factor)
d | Duration to divide |
factor | Division factor |
Division operator (duration / duration)
lhs | Left operand |
rhs | Right operand |