13#include "qx/core/qx-global.h"
20 requires std::signed_integral<T>
25 enum class Type {Null,
End, Value};
50 mValue = std::numeric_limits<T>::max();
54 qCritical(
"Invalid extent");
71 bool isNull()
const {
return mType == Type::Null; }
72 bool isLast()
const {
return mType == Type::End; }
76 bool operator==(
const Index& other)
const noexcept {
return mType == other.mType && mValue == other.mValue; }
85 return other.mType == Type::Null ? std::strong_ordering::equal : std::strong_ordering::less;
88 return other.mType == Type::End ? std::strong_ordering::equal : std::strong_ordering::greater;
92 return other.mType == Type::Null ? std::strong_ordering::greater :
93 other.mType == Type::End ? std::strong_ordering::less :
94 mValue <=> other.mValue;
101 if(other.mType == Type::End)
103 else if(mType == Type::End)
113 return (mType == Type::End || other.mType == Type::End) ?
122 if(other.mValue == 0)
123 qFatal(
"Divide by zero");
125 if(other.mType == Type::End)
126 return mType == Type::End ? 1 : 0;
127 else if(mType == Type::End)
137 if(mValue == 0 || other.mValue == 0)
139 else if(mType == Type::End || other.mType == Type::End)
151 if(mType == Type::Value && mValue != std::numeric_limits<T>::max())
163 if(!mType == Type::Value && mValue != 0)
The Index template class provides a wrapper for integers with the notion of 'first',...
Definition qx-index.h:22
bool isNull() const
Definition qx-index.h:71
Index & operator*=(const Index &other)
Definition qx-index.h:146
Index operator/(const Index &other)
Definition qx-index.h:120
T & operator*()
Definition qx-index.h:174
Index & operator+=(const Index &other)
Definition qx-index.h:118
Index operator-(const Index &other)
Definition qx-index.h:99
Index & operator--()
Definition qx-index.h:161
bool isLast() const
Definition qx-index.h:72
Index operator*(const Index &other)
Definition qx-index.h:135
Index operator+(const Index &other)
Definition qx-index.h:111
Index & operator++()
Definition qx-index.h:149
Index & operator-=(const Index &other)
Definition qx-index.h:109
Index & operator/=(const Index &other)
Definition qx-index.h:133
bool operator==(const Index &other) const noexcept
Definition qx-index.h:76
constexpr Index(Extent e)
Definition qx-index.h:39
constexpr Index()
Definition qx-index.h:34
Index operator--(int)
Definition qx-index.h:167
std::strong_ordering operator<=>(const Index &other) const noexcept
Definition qx-index.h:81
Index operator++(int)
Definition qx-index.h:155
constexpr Index(T value)
Definition qx-index.h:58
The Qx namespace is the main namespace through which all non-global functionality of the Qx library i...
Definition qx-processwaiter.cpp:5
Extent
Definition qx-global.h:18
@ Last
Definition qx-global.h:21
@ End
Definition qx-global.h:22
@ First
Definition qx-global.h:19
T constrainedAdd(T a, T b, T min=std::numeric_limits< T >::min(), T max=std::numeric_limits< T >::max())
Definition qx-algorithm.h:65
T constrainedDiv(T a, T b, T min=std::numeric_limits< T >::min(), T max=std::numeric_limits< T >::max())
Definition qx-algorithm.h:141
Index< qint32 > Index64
Definition qx-index.h:304
T constrainedSub(T a, T b, T min=std::numeric_limits< T >::min(), T max=std::numeric_limits< T >::max())
Definition qx-algorithm.h:87
Index< qint32 > Index32
Definition qx-index.h:303
Index< qint8 > Index8
Definition qx-index.h:301
Index< qint16 > Index16
Definition qx-index.h:302
T constrainedMult(T a, T b, T min=std::numeric_limits< T >::min(), T max=std::numeric_limits< T >::max())
Definition qx-algorithm.h:109
The qx-algorithm header file provides various mathematical/algorithmic functions.