Units and Versions

Integer Indexes, Amounts, Offsets and Ranges

Scalar Arithmetic

Integer unit lengths and offsets support scalar multiplication, division and modulo while preserving their unit type. Lengths require unsigned scalar operands. Offsets require signed scalar operands. Scalar operands may be native integer types or SaturatingInteger values.

Unit values are not multiplied, divided or modulo-applied with other unit values. Indexes also keep their stricter domain model and can only be moved with matching lengths and offsets. The uncheckedAdvance() and uncheckedIncrement() operations are reserved for measured low-level loops whose finite inputs and valid result bounds are already proven. Regular code uses the checked, saturating index operations.

Finite length multiplication saturates at the largest finite length. Infinite lengths remain infinite for scalar multiplication, division and modulo. Division and modulo by zero terminate, matching the saturating integer helpers.

Version

Introduction

Version stores a four-part version as major, minor, revision, and build number. The default value is 0.0.0.0. You can construct versions from raw part values or from typed part values in any order:

auto api = el::Version{1, 2, 0};
auto selected = el::Version{el::Major{13}, el::Revision{2}}

Precision

compare() accepts a VersionPart as precision. The selected part is the last compared part. For example, minor precision compares major and minor, while revision and build are ignored.

Numeric Representation

toNumber() packs the four 16-bit parts into a uint64_t as major << 48 | minor << 32 | revision << 16 | build. This keeps numeric ordering identical to full version ordering.

Version Part

VersionPart identifies the part of a Version. It is also used as comparison precision: the selected part is included, and less-significant parts are ignored.

Version Range

VersionRange stores optional inclusive minimum and maximum version bounds. Missing bounds are open-ended, so a default range contains every version.

Containment uses the same precision rules as Version::compare. If both bounds are present and the minimum is greater than the maximum at the selected precision, the range is empty.

Common Ranges

Use all() for an open range, atLeast() for a lower-bounded range, atMost() for an upper-bounded range, between() for inclusive minimum and maximum bounds, and exact() for a single version.

Version Unit

VersionUnit is the shared base unit for unsigned 16-bit version components. It disables the noIndex() sentinel so the full 16-bit range is available to IntegerUnitIndex. Use the public aliases Major, Minor, Revision, and BuildNumber in user code.

The concrete units MajorUnit, MinorUnit, RevisionUnit, and BuildNumberUnit keep the represented VersionPart in the type.

Interface

struct ArgumentUnit : public erbsland::unit::IntegerUnit

The integer unit for argument types.

Public Types

using IndexType = uint32_t

The unsigned integer type for indexes.

using AmountType = uint32_t

The unsigned integer type for amounts.

using OffsetType = int32_t

The signed integer type for offsets.

using erbsland::unit::ArgumentIndex = IntegerUnitIndex<ArgumentUnit>

An argument index.

using erbsland::unit::ArgumentCount = IntegerUnitAmount<ArgumentUnit>

An argument count.

using erbsland::unit::ByteIndex = IntegerUnitIndex<ByteUnit>

A byte-based index.

using erbsland::unit::ByteLength = IntegerUnitAmount<ByteUnit>

A byte-based length.

using erbsland::unit::ByteOffset = IntegerUnitOffset<ByteUnit>

A byte-based offset.

using erbsland::unit::ByteRange = IntegerUnitRange<ByteUnit>

A byte-based range.

struct ByteUnit : public erbsland::unit::IntegerUnit

The integer unit for byte-based types.

struct CodeContinuousRange

A continuous source code range with an exclusive end location.

Public Members

CodeLocation begin

The inclusive begin location.

CodeLocation end

The exclusive end location.

class CodeLocation

A source code location with optional line, column and code-point position.

Public Functions

constexpr CodeLocation() noexcept = default

Create an undefined code location.

inline constexpr CodeLocation(LineIndex line, ColumnIndex column = ColumnIndex::noIndex(), CpIndex position = CpIndex::noIndex()) noexcept

Create a code location from its optional components.

inline constexpr LineIndex line() const noexcept

Get the zero-based line index.

inline constexpr CodeLocation &setLine(LineIndex line) noexcept

Set the zero-based line index.

inline constexpr ColumnIndex column() const noexcept

Get the zero-based column index.

inline constexpr CodeLocation &setColumn(ColumnIndex column) noexcept

Set the zero-based column index.

inline constexpr CpIndex position() const noexcept

Get the zero-based absolute code-point position.

inline constexpr CodeLocation &setPosition(CpIndex position) noexcept

Set the zero-based absolute code-point position.

bool operator==(const CodeLocation&) const noexcept = default

Compare two locations.

bool isUndefined() const noexcept

Test if no location component is defined.

void nextLine() noexcept

Advance to the first character of the next line.

void nextColumn() noexcept

Advance to the next character in the current line.

text::String toString() const noexcept

Format the known location in one-based, human-readable form.

using erbsland::unit::ColumnCount = IntegerUnitAmount<ColumnUnit>

A source code column count.

using erbsland::unit::ColumnIndex = IntegerUnitIndex<ColumnUnit>

A zero-based source code column index.

using erbsland::unit::ColumnOffset = IntegerUnitOffset<ColumnUnit>

A signed source code column offset.

using erbsland::unit::ColumnRange = IntegerUnitRange<ColumnUnit>

A range of source code columns.

struct ColumnUnit : public erbsland::unit::IntegerUnit

The integer unit for source code column types.

Public Types

using IndexType = uint32_t

The unsigned integer type for indexes.

using AmountType = uint32_t

The unsigned integer type for amounts.

using OffsetType = int32_t

The signed integer type for offsets.

using erbsland::unit::CpIndex = IntegerUnitIndex<CpUnit>

A Unicode code-point-based index.

using erbsland::unit::CpLength = IntegerUnitAmount<CpUnit>

A Unicode code-point-based length.

using erbsland::unit::CpOffset = IntegerUnitOffset<CpUnit>

A Unicode code-point-based offset.

using erbsland::unit::CpRange = IntegerUnitRange<CpUnit>

A Unicode code-point-based range.

struct CpUnit : public erbsland::unit::IntegerUnit

The integer unit Unicode code-point-based types.

Public Types

using IndexType = uint32_t

The unsigned integer type for indexes.

using AmountType = uint32_t

The unsigned integer type for amounts.

using OffsetType = int32_t

The signed integer type for offsets.

class ExitCode

Represents an exit code for a program.

Public Types

using Value = int32_t

The raw exit-code value type.

Public Functions

inline explicit constexpr ExitCode(const Value exitCode)

Create an exit code from a given generic integer value.

inline bool isSuccess() const noexcept

Test if the exit-code is zero.

inline bool isFailure() const noexcept

Test if the exit-code is not zero.

inline bool isZero() const noexcept

Test if the exit-code is zero.

inline bool isOne() const noexcept

Test if the exit-code is one.

inline bool isMinimum() const noexcept

Test if the exit-code is at its minimum value.

inline bool isMaximum() const noexcept

Test if the exit-code is at its maximum value.

inline bool isValidPosix() const noexcept

Test if the exit code is in valid POSIX range.

inline bool isRecommendedPosix() const noexcept

Test if the exit code is in the recommended POSIX range.

inline Value toRawValue() const noexcept

Access the raw underlying value.

inline ExitCode toRecommendedPosix() const noexcept

Convert the exit code to the recommended POSIX range.

Public Static Functions

static inline constexpr ExitCode success() noexcept

Get a zero exit-code, indicating success.

static inline constexpr ExitCode failure() noexcept

Get a one exit-code, indicating a generic failure.

static inline constexpr ExitCode zero() noexcept

Get a zero exit-code.

static inline constexpr ExitCode one() noexcept

Get a one exit-code.

static inline constexpr ExitCode minimum() noexcept

Get the minimum possible exit code.

static inline constexpr ExitCode maximum() noexcept

get the maximum possible exit code.

template<typename tUnit, typename tRatio, typename tValue>
class IntegerAmount

A signed integer amount in a ratio-scaled unit.

This type is intended for values such as seconds, milliseconds, meters, or kilometers where signed arithmetic, ratio conversion, and saturating integer behavior are desired.

See: Units and Versions

Template Parameters:
  • tUnit – The unit tag that prevents accidental mixing with unrelated amounts.

  • tRatio – The ratio of this amount to its base unit.

  • tValue – The signed saturating integer type used to store the amount.

Public Types

using Unit = tUnit

The unit tag.

using Ratio = tRatio

The ratio to the base unit.

using Value = tValue

The saturating integer value type.

using NativeValue = math::NativeIntegerOfT<Value>

The native signed integer type wrapped by Value.

Public Functions

constexpr IntegerAmount() noexcept = default

Create a zero amount.

inline explicit constexpr IntegerAmount(Value value) noexcept

Create an amount from a saturating integer value.

inline explicit constexpr IntegerAmount(NativeValue value) noexcept

Create an amount from a native signed integer value.

template<impl::SignedIntegerAmountOperand tOther>
inline explicit constexpr IntegerAmount(tOther value) noexcept

Create an amount from another signed integer operand, saturating if needed.

inline constexpr std::strong_ordering operator<=>(const IntegerAmount &other) const noexcept

Compare this amount with another amount of the exact same type.

inline IntegerAmount operator+(IntegerAmount other) const noexcept

Add another amount, saturating on overflow.

inline IntegerAmount &operator+=(IntegerAmount other) noexcept

Add another amount in place, saturating on overflow.

inline IntegerAmount operator-(IntegerAmount other) const noexcept

Subtract another amount, saturating on underflow.

inline IntegerAmount &operator-=(IntegerAmount other) noexcept

Subtract another amount in place, saturating on underflow.

inline IntegerAmount operator-() const noexcept

Return the negated amount, saturating the minimum value to the maximum value.

inline IntegerAmount &operator++() noexcept

Increment this amount by one, saturating at maximum().

inline IntegerAmount operator++(int) noexcept

Increment this amount by one and return the previous value.

inline IntegerAmount &operator--() noexcept

Decrement this amount by one, saturating at minimum().

inline IntegerAmount operator--(int) noexcept

Decrement this amount by one and return the previous value.

template<impl::SignedIntegerAmountOperand tFactor>
inline IntegerAmount operator*(tFactor factor) const noexcept

Multiply this amount by a signed integer factor.

template<impl::SignedIntegerAmountOperand tFactor>
inline IntegerAmount &operator*=(tFactor factor) noexcept

Multiply this amount in place by a signed integer factor.

template<impl::SignedIntegerAmountOperand tDivisor>
inline IntegerAmount operator/(tDivisor divisor) const noexcept

Divide this amount by a signed integer divisor.

template<impl::SignedIntegerAmountOperand tDivisor>
inline IntegerAmount &operator/=(tDivisor divisor) noexcept

Divide this amount in place by a signed integer divisor.

template<impl::SignedIntegerAmountOperand tModulus>
inline IntegerAmount operator%(tModulus modulus) const noexcept

Modulo this amount by a signed integer factor.

template<impl::SignedIntegerAmountOperand tModulus>
inline IntegerAmount &operator%=(tModulus modulus) noexcept

Modulo an amount by another amount.

inline constexpr bool isZero() const noexcept

Test if this amount is zero.

inline constexpr bool isOne() const noexcept

Test if this amount is one.

inline constexpr bool isMinusOne() const noexcept

Test if this amount is minus one.

inline constexpr bool isPositive() const noexcept

Test if this amount is positive.

inline constexpr bool isNegative() const noexcept

Test if this amount is negative.

inline constexpr bool isMinimum() const noexcept

Test if this amount has the minimum representable value.

inline constexpr bool isMaximum() const noexcept

Test if this amount has the maximum representable value.

inline constexpr bool wouldAddSaturate(const IntegerAmount &other) const noexcept

Test if adding would saturate.

inline constexpr bool wouldSubtractSaturate(const IntegerAmount &other) const noexcept

Test if subtracting would saturate.

template<impl::SignedIntegerAmountOperand tFactor>
inline constexpr bool wouldMultiplySaturate(const tFactor &other) const noexcept

Test if multiplying would saturate.

inline constexpr NativeValue toRawValue() const noexcept

Access the raw native signed integer value.

inline constexpr Value toValue() const noexcept

Access the saturating integer value.

inline constexpr std::strong_ordering compare(const IntegerAmount &other) const noexcept

Compare this amount with another amount of the exact same type.

inline IntegerAmount<Unit, std::ratio<1>, Value> toBaseUnit() const noexcept

Convert this amount to the base unit for its unit tag.

inline IntegerAmount<Unit, std::ratio<1>, Value> toBaseUnitOrThrow() const

Convert this amount to the base unit for its unit tag.

Throws:

err::OverflowError – if the conversion would saturate.

template<typename tTarget>
inline bool wouldConvertSaturate() const noexcept

Test if conversion to another ratio with the same unit tag would saturate.

template<typename tTarget>
inline tTarget converted() const noexcept

Convert this amount to another ratio with the same unit tag.

template<typename tTarget>
inline tTarget convertedOrThrow() const

Convert this amount to another ratio with the same unit tag.

Throws:

err::OverflowError – if the conversion would saturate.

template<typename tTarget>
inline tTarget convert() const noexcept

Compatibility alias for converted.

template<typename tTarget>
inline tTarget convertOrThrow() const

Compatibility alias for convertedOrThrow.

Throws:

err::OverflowError – if the conversion would saturate.

template<typename tTarget>
inline tTarget extract() noexcept

Extract a larger whole unit and keep the signed remainder in this amount.

inline IntegerAmount negated() const noexcept

Return the negated amount, saturating the minimum value to the maximum value.

inline void negate() noexcept

Negate this amount in place, saturating the minimum value to the maximum value.

inline IntegerAmount clamped(IntegerAmount first, IntegerAmount last) const noexcept

Return this amount clamped to the given inclusive range.

inline void clamp(IntegerAmount first, IntegerAmount last) noexcept

Clamp this amount to the given inclusive range.

inline IntegerAmount toAbsolute() const noexcept

Return the absolute value of this amount.

Public Static Functions

static inline constexpr IntegerAmount zero() noexcept

Return the zero amount.

static inline constexpr IntegerAmount one() noexcept

Return the amount one.

static inline constexpr IntegerAmount minusOne() noexcept

Return the amount minus one.

static inline constexpr IntegerAmount minimum() noexcept

Return the smallest representable amount.

static inline constexpr IntegerAmount maximum() noexcept

Return the largest representable amount.

static inline constexpr std::intmax_t ratioNumerator() noexcept

Return the ratio numerator.

static inline constexpr std::intmax_t ratioDenominator() noexcept

Return the ratio denominator.

static inline constexpr bool isBaseUnit() noexcept

Test if this amount is measured in the base unit.

Public Static Attributes

static constexpr auto cIsIntegerAmount = true

Marker used by concepts to identify integer amount types.

Friends

template<impl::SignedIntegerAmountOperand tFactor>
inline friend IntegerAmount operator*(tFactor factor, IntegerAmount amount) noexcept

Multiply a signed integer factor by an amount.

struct IntegerUnit

The base class for all integer units.

Subclassed by erbsland::cterm::BlockUnit, erbsland::unit::ArgumentUnit, erbsland::unit::ByteUnit, erbsland::unit::ColumnUnit, erbsland::unit::CpUnit, erbsland::unit::ItemUnit, erbsland::unit::LineUnit, erbsland::unit::U16DataUnit, erbsland::unit::VersionUnit

Public Types

using IndexType = uint64_t

The unsigned integer type for indexes.

using AmountType = uint64_t

The unsigned integer type for amounts.

using OffsetType = int64_t

The signed integer type for offsets.

Public Static Attributes

static constexpr auto cHasNoIndex = true

Whether indexes reserve a no-index state.

template<impl::ValidIntegerUnit tIntegerUnit>
class IntegerUnitAmount

A non-negative length with a integer unit.

See: Units and Versions

Template Parameters:

tIntegerUnit – The integer unit for this length.

Public Types

using Value = tIntegerUnit::AmountType

The raw unsigned integer type.

using Unit = tIntegerUnit

The unit type.

Public Functions

constexpr IntegerUnitAmount() noexcept = default

Create a zero length.

inline explicit constexpr IntegerUnitAmount(Value value) noexcept

Create a length from a raw value.

Parameters:

value – The raw value. Passing cInfinite creates the special infinite length.

inline constexpr IntegerUnitAmount operator+(const IntegerUnitAmount other) const noexcept

Add another length and return the saturated result.

inline IntegerUnitAmount &operator+=(const IntegerUnitAmount other) noexcept

Add another length to this length with saturation.

inline constexpr IntegerUnitAmount operator-(const IntegerUnitAmount other) const noexcept

Subtract another length and return the saturated result.

inline IntegerUnitAmount &operator-=(const IntegerUnitAmount other) noexcept

Subtract another length from this length with saturation.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitAmount operator*(T scalar) const noexcept

Multiply this length by an unsigned scalar and return the saturated result.

template<math::AnyIntegerType T>
inline IntegerUnitAmount &operator*=(T scalar) noexcept

Multiply this length by an unsigned scalar with saturation.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitAmount operator/(T scalar) const noexcept

Divide this length by an unsigned scalar.

template<math::AnyIntegerType T>
inline IntegerUnitAmount &operator/=(T scalar) noexcept

Divide this length by an unsigned scalar.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitAmount operator%(T scalar) const noexcept

Calculate the modulo of this length and an unsigned scalar.

template<math::AnyIntegerType T>
inline IntegerUnitAmount &operator%=(T scalar) noexcept

Apply modulo with an unsigned scalar.

inline IntegerUnitAmount &operator++() noexcept

Increment this length by one with saturation.

inline IntegerUnitAmount operator++(int) noexcept

Increment this length by one with saturation and return the previous value.

inline IntegerUnitAmount &operator--() noexcept

Decrement this length by one with saturation.

inline IntegerUnitAmount operator--(int) noexcept

Decrement this length by one with saturation and return the previous value.

inline constexpr bool isZero() const noexcept

Test if this length is zero.

inline constexpr bool isOne() const noexcept

Test if this length is one.

inline constexpr bool isMinimum() const noexcept

Test if this length has the minimum value.

inline constexpr bool isMaximum() const noexcept

Test if this length has the largest finite value.

inline constexpr bool isInfinite() const noexcept

Test if this length has the infinite value.

inline constexpr bool isFinite() const noexcept

Test if this length has a finite value.

inline constexpr Value toRawValue() const noexcept

Access the raw value of this length.

inline constexpr bool wouldAddSaturate(const IntegerUnitAmount other) const noexcept

Test if adding another length would saturate this length.

inline IntegerUnitAmount &add(const IntegerUnitAmount other) noexcept

Add another length, saturating at the largest finite length or infinite length.

If either operand is infinite, the result is infinite.

inline constexpr IntegerUnitAmount added(const IntegerUnitAmount other) const noexcept

Create a new length by adding another length to it.

If either operand is infinite, the result is infinite.

inline IntegerUnitAmount &addOrThrow(const IntegerUnitAmount other)

Add another length.

Throws:

OverflowError – if either operand is infinite or the finite result exceeds maximum().

inline constexpr IntegerUnitAmount addedOrThrow(const IntegerUnitAmount other) const

Create a new length by adding another length to it.

Throws:

OverflowError – if either operand is infinite or the finite result exceeds maximum().

inline constexpr bool wouldSubtractSaturate(const IntegerUnitAmount other) const noexcept

Test if subtracting another length would saturate this length.

inline IntegerUnitAmount &subtract(const IntegerUnitAmount other) noexcept

Subtract another length, saturating at zero.

If this length is infinite, it remains infinite. Subtracting infinite from a finite length produces zero.

inline constexpr IntegerUnitAmount subtracted(const IntegerUnitAmount other) const noexcept

Create a new length by subtracting another length from it.

If this length is infinite, the result is infinite. Subtracting infinite from a finite length produces zero.

inline IntegerUnitAmount &subtractOrThrow(const IntegerUnitAmount other)

Subtract another length.

Throws:

OverflowError – if either operand is infinite or the finite result would be below zero.

inline constexpr IntegerUnitAmount subtractedOrThrow(const IntegerUnitAmount other) const

Create a new length by subtracting another length from it.

Throws:

OverflowError – if either operand is infinite or the finite result would be below zero.

template<math::AnyIntegerType T>
inline bool wouldMultiplySaturate(T scalar) const noexcept

Test if a multiplication would saturate.

template<math::AnyIntegerType T>
inline IntegerUnitAmount &multiply(T scalar) noexcept

Multiply this length by an unsigned scalar with saturation.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitAmount multiplied(T scalar) const noexcept

Create a new length by multiplying this length with an unsigned scalar.

Infinite lengths stay infinite.

template<math::AnyIntegerType T>
inline IntegerUnitAmount &divide(T scalar) noexcept

Divide this length by an unsigned scalar.

Infinite lengths stay infinite.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitAmount divided(T scalar) const noexcept

Create a new length by dividing this length by an unsigned scalar.

Infinite lengths stay infinite.

template<math::AnyIntegerType T>
inline IntegerUnitAmount &applyModulo(T scalar) noexcept

Apply modulo with an unsigned scalar.

Infinite lengths stay infinite.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitAmount modulo(T scalar) const noexcept

Calculate the modulo of this length and an unsigned scalar.

Infinite lengths stay infinite.

inline constexpr std::size_t toSizeT() const noexcept

Convert this length to std::size_t, saturating if the raw value is too large.

inline constexpr std::size_t toSizeTOrThrow() const

Convert this length to std::size_t.

Throws:

OverflowError – if the raw value does not fit into std::size_t.

Public Static Functions

static inline constexpr IntegerUnitAmount zero() noexcept

Return the zero length.

static inline constexpr IntegerUnitAmount one() noexcept

Return the length one.

static inline constexpr IntegerUnitAmount minimum() noexcept

Return the smallest finite length.

static inline constexpr IntegerUnitAmount maximum() noexcept

Return the largest finite length.

static inline constexpr IntegerUnitAmount infinite() noexcept

Return the special infinite length.

static inline constexpr IntegerUnitAmount fromSizeT(const std::size_t value) noexcept

Create an index from a size_t value.

Saturating if the value overflows.

static inline constexpr IntegerUnitAmount fromSizeTOrThrow(const std::size_t value)

Create an index from a size_t value.

Throws:

OverflowError – if the size_t value exceeds the maximum index.

Public Static Attributes

static constexpr Value cRawInfinite = std::numeric_limits<Value>::max()

The raw value used for the special infinite length.

static constexpr Value cRawMaximum = cRawInfinite - 1U

The largest finite raw value.

template<impl::ValidIntegerUnit tIntegerUnit>
class IntegerUnitIndex

An integer index with a unit.

See: Units and Versions

Template Parameters:

tIntegerUnit – The integer unit for this index.

Public Types

using Value = tIntegerUnit::IndexType

The raw unsigned integer type.

using Unit = tIntegerUnit

The unit type.

using Length = IntegerUnitAmount<tIntegerUnit>

The matching length type.

using Offset = IntegerUnitOffset<tIntegerUnit>

The matching offset type.

Public Functions

constexpr IntegerUnitIndex() noexcept = default

Create a zero index.

inline explicit constexpr IntegerUnitIndex(Value value) noexcept

Create an index from a raw value.

Parameters:

value – The raw value. Passing cRawNoIndex creates the special no-index value if the unit supports it.

inline constexpr IntegerUnitIndex operator+(const Length length) const noexcept

Advance this index by a length and return the saturated result.

inline IntegerUnitIndex &operator+=(const Length length) noexcept

Advance this index by a length with saturation.

inline constexpr IntegerUnitIndex operator-(const Length length) const noexcept

Retreat this index by a length and return the saturated result.

inline IntegerUnitIndex &operator-=(const Length length) noexcept

Retreat this index by a length with saturation.

inline constexpr IntegerUnitIndex operator+(const Offset offset) const noexcept

Move this index by an offset and return the saturated result.

inline IntegerUnitIndex &operator+=(const Offset offset) noexcept

Move this index by an offset with saturation.

inline constexpr IntegerUnitIndex operator-(const Offset offset) const noexcept

Move this index by the negated offset and return the saturated result.

inline IntegerUnitIndex &operator-=(const Offset offset) noexcept

Move this index by the negated offset with saturation.

inline IntegerUnitIndex &operator++() noexcept

Increment this index by one with saturation.

inline IntegerUnitIndex operator++(int) noexcept

Increment this index by one with saturation and return the previous value.

inline IntegerUnitIndex &operator--() noexcept

Decrement this index by one with saturation.

inline IntegerUnitIndex operator--(int) noexcept

Decrement this index by one with saturation and return the previous value.

inline constexpr bool isZero() const noexcept

Test if this index is zero.

inline constexpr bool isOne() const noexcept

Test if this index is one.

inline constexpr bool isMinimum() const noexcept

Test if this index is at its minimum.

inline constexpr bool isMaximum() const noexcept

Test if this index is at its largest valid value.

inline constexpr bool isNoIndex() const noexcept

Test if this index is the special no-index value.

inline constexpr bool isValid() const noexcept

Test if this index is a valid position.

inline constexpr bool isWithin(const Length length) const noexcept

Test if this index is a valid position within the given length.

inline constexpr bool wouldBeWithinAfterAdvance(const Length step, const Length bounds) const noexcept

Test if advancing by the given length would keep this index within the given bounds.

inline constexpr bool wouldBeWithinAfterRetreat(const Length step, const Length bounds) const noexcept

Test if retreating by the given length would keep this index within the given bounds.

inline constexpr bool wouldBeWithinAfterMove(const Offset offset, const Length bounds) const noexcept

Test if moving by the given offset would keep this index within the given bounds.

inline constexpr bool wouldOffsetFromZeroSaturate() const noexcept

Test if offsetFromZero() would return a saturated result.

inline constexpr bool wouldOffsetToSaturate(const IntegerUnitIndex &other) const noexcept

Test if offsetTo() would return a saturated result.

inline constexpr Value toRawValue() const noexcept

Access the raw value of this index.

inline IntegerUnitIndex &advance(const Length length) noexcept

Advance this index by a non-negative length.

Saturates at maximum() and keeps noIndex() unchanged.

inline IntegerUnitIndex &advanceOrThrow(const Length length)

Advance this index by a non-negative length.

Throws:

OverflowError – if this index is noIndex() or the result would exceed maximum().

inline constexpr IntegerUnitIndex advanced(const Length length) const noexcept

Create a new index advanced by a non-negative length.

Saturates at maximum() and keeps noIndex() unchanged.

inline constexpr IntegerUnitIndex advancedOrThrow(const Length length) const

Create a new index advanced by a non-negative length.

Throws:

OverflowError – if this index is noIndex() or the result would exceed maximum().

inline IntegerUnitIndex &retreat(const Length length) noexcept

Retreat this index by a non-negative length.

Saturates at zero and keeps noIndex() unchanged.

inline IntegerUnitIndex &retreatOrThrow(const Length length)

Retreat this index by a non-negative length.

Throws:

OverflowError – if this index is noIndex() or the result would be before zero.

inline constexpr IntegerUnitIndex retreated(const Length length) const noexcept

Create a new index retreated by a non-negative length.

Saturates at zero and keeps noIndex() unchanged.

inline constexpr IntegerUnitIndex retreatedOrThrow(const Length length) const

Create a new index retreated by a non-negative length.

Throws:

OverflowError – if this index is noIndex() or the result would be before zero.

inline IntegerUnitIndex &move(const Offset offset) noexcept

Move this index by a signed offset.

Saturates at zero or maximum() and keeps noIndex() unchanged.

inline IntegerUnitIndex &moveOrThrow(const Offset offset)

Move this index by a signed offset.

Throws:

OverflowError – if this index is noIndex() or the result would be outside zero to maximum().

inline constexpr IntegerUnitIndex moved(const Offset offset) const noexcept

Create a new index moved by a signed offset.

Saturates at zero or maximum() and keeps noIndex() unchanged.

inline constexpr IntegerUnitIndex movedOrThrow(const Offset offset) const

Create a new index moved by a signed offset.

Throws:

OverflowError – if this index is noIndex() or the result would be outside zero to maximum().

inline IntegerUnitIndex &increment() noexcept

Increment this index by one.

inline IntegerUnitIndex &decrement() noexcept

Decrement this index by one.

inline constexpr IntegerUnitIndex incremented() const noexcept

Create a new index incremented by one.

inline constexpr IntegerUnitIndex decremented() const noexcept

Create a new index decremented by one.

inline constexpr IntegerUnitIndex &uncheckedAdvance(const Length length) noexcept

Advance this index without checking special states or arithmetic bounds.

The caller must ensure this index and length are finite and that the result remains a valid index.

inline constexpr IntegerUnitIndex &uncheckedIncrement() noexcept

Increment this index without checking special states or arithmetic bounds.

The caller must ensure this is a valid index below maximum().

inline IntegerUnitIndex flipped(Length length) const noexcept

Return the index, flipped in the given range.

inline constexpr Length distanceFromZero() const noexcept

Get the distance from zero to this index.

Returns:

The distance from zero, or infinite if this index is noIndex().

inline constexpr Length absoluteDistanceTo(const IntegerUnitIndex &other) const noexcept

Get the absolute distance from this index to another index.

Returns:

The absolute distance, or infinite if either index is noIndex().

inline constexpr Offset offsetFromZero() const noexcept

Get the signed offset from zero to this index.

Returns:

The offset from zero, saturated to Offset::maximum() if this index is noIndex() or too large.

inline constexpr Offset offsetFromZeroOrThrow() const

Get the signed offset from zero to this index.

Throws:

OverflowError – if this index is noIndex() or the result does not fit into Offset.

inline constexpr Offset offsetTo(const IntegerUnitIndex &other) const noexcept

Get the signed offset from this index to another index.

Returns:

The directional offset, saturated to Offset::minimum() or Offset::maximum() if necessary. If either index is noIndex(), this returns Offset::maximum().

inline constexpr Offset offsetToOrThrow(const IntegerUnitIndex &other) const

Get the signed offset from this index to another index.

Throws:

OverflowError – if either index is noIndex() or the result does not fit into Offset.

inline constexpr std::size_t toSizeT() const noexcept

Convert this index to std::size_t, saturating if the raw value is too large.

inline constexpr std::size_t toSizeTOrThrow() const

Convert this index to std::size_t.

Throws:

OverflowError – if the raw value does not fit into std::size_t.

Public Static Functions

static inline auto fromGrid(const IntegerUnitIndex x, const IntegerUnitIndex y, const Length width, const Length height) noexcept -> IntegerUnitIndex

Create a grid index from row and column indices, bound to with and height of a grid.

A grid index is a sequential index that represents a position in a grid. If x or y are out of bounds, or any of the parameters is infinite or no index, returns noIndex.

Parameters:
  • x – The index in the x position.

  • y – The index in the y position.

  • width – The width of the grid.

  • height – The height of the grid.

Returns:

The grid index or noIndex if any parameter is invalid.

static inline constexpr IntegerUnitIndex minimum() noexcept

Return the smallest valid index.

static inline constexpr IntegerUnitIndex maximum() noexcept

Return the largest valid index.

static inline constexpr IntegerUnitIndex zero() noexcept

Return the zero index.

static inline constexpr IntegerUnitIndex one() noexcept

Return the index one.

static inline constexpr IntegerUnitIndex noIndex() noexcept

Return the special no-index value.

static inline constexpr IntegerUnitIndex end(const Length length) noexcept

Return the end index for a length measured from zero.

Infinite length is converted into noIndex().

static inline constexpr IntegerUnitIndex fromSizeT(const std::size_t value) noexcept

Create an index from a size_t value.

Saturating if the value overflows.

static inline constexpr IntegerUnitIndex fromSizeTOrThrow(const std::size_t value)

Create an index from a size_t value.

Throws:

OverflowError – if the size_t value exceeds the maximum index.

Public Static Attributes

static constexpr auto cHasNoIndex = tIntegerUnit::cHasNoIndex

Whether this index reserves a special no-index state.

static constexpr Value cRawNoIndex = std::numeric_limits<Value>::max()

The raw value used for the special no-index state.

static constexpr Value cRawMaximum = cHasNoIndex ? static_cast<Value>(cRawNoIndex - Value{1U}) : cRawNoIndex

The largest valid raw index value.

Friends

inline friend void swap(IntegerUnitIndex &first, IntegerUnitIndex &second) noexcept

Swap two indexes.

template<impl::ValidIntegerUnit tIntegerUnit>
class IntegerUnitOffset

A signed offset with a unit tag.

An offset describes movement relative to an index. Positive offsets move forward, negative offsets move backward. Use IntegerUnitAmount for non-negative spans and counts.

Template Parameters:

tIntegerUnit – The unit tag for this offset.

Public Types

using Value = tIntegerUnit::OffsetType

The raw signed integer type.

using Unit = tIntegerUnit

The unit type.

using Length = IntegerUnitAmount<tIntegerUnit>

The matching length type.

Public Functions

constexpr IntegerUnitOffset() noexcept = default

Create a zero offset.

inline explicit constexpr IntegerUnitOffset(Value value) noexcept

Create an offset from a raw value.

inline constexpr IntegerUnitOffset operator+(const IntegerUnitOffset other) const noexcept

Add another offset and return the saturated result.

inline IntegerUnitOffset &operator+=(const IntegerUnitOffset other) noexcept

Add another offset to this offset with saturation.

inline constexpr IntegerUnitOffset operator-(const IntegerUnitOffset other) const noexcept

Subtract another offset and return the saturated result.

inline IntegerUnitOffset &operator-=(const IntegerUnitOffset other) noexcept

Subtract another offset from this offset with saturation.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitOffset operator*(T scalar) const noexcept

Multiply this offset by a signed scalar and return the saturated result.

template<math::AnyIntegerType T>
inline IntegerUnitOffset &operator*=(T scalar) noexcept

Multiply this offset by a signed scalar with saturation.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitOffset operator/(T scalar) const noexcept

Divide this offset by a signed scalar.

template<math::AnyIntegerType T>
inline IntegerUnitOffset &operator/=(T scalar) noexcept

Divide this offset by a signed scalar.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitOffset operator%(T scalar) const noexcept

Calculate the modulo of this offset and a signed scalar.

template<math::AnyIntegerType T>
inline IntegerUnitOffset &operator%=(T scalar) noexcept

Apply modulo with a signed scalar.

inline constexpr IntegerUnitOffset operator-() const noexcept

Return this offset with the sign inverted, saturating minimum() to maximum().

inline IntegerUnitOffset &operator++() noexcept

Increment this offset by one with saturation.

inline IntegerUnitOffset operator++(int) noexcept

Increment this offset by one with saturation and return the previous value.

inline IntegerUnitOffset &operator--() noexcept

Decrement this offset by one with saturation.

inline IntegerUnitOffset operator--(int) noexcept

Decrement this offset by one with saturation and return the previous value.

inline constexpr bool isZero() const noexcept

Test if this offset is zero.

inline constexpr bool isOne() const noexcept

Test if this offset is one.

inline constexpr bool isMinusOne() const noexcept

Test if this offset is negative one.

inline constexpr bool isNegative() const noexcept

Test if this offset is less than zero.

inline constexpr bool isPositive() const noexcept

Test if this offset is greater than zero.

inline constexpr bool isMinimum() const noexcept

Test if this offset has the minimum value.

inline constexpr bool isMaximum() const noexcept

Test if this offset has the maximum value.

inline constexpr Value toRawValue() const noexcept

Access the raw value of this offset.

inline constexpr Length absoluteLength() const noexcept

Convert this offset into the matching non-negative length.

inline constexpr bool wouldAddSaturate(const IntegerUnitOffset other) const noexcept

Test if adding another offset would saturate this offset.

inline IntegerUnitOffset &add(const IntegerUnitOffset other) noexcept

Add another offset, saturating at minimum() or maximum().

inline constexpr IntegerUnitOffset added(const IntegerUnitOffset other) const noexcept

Create a new offset by adding another offset to it.

inline IntegerUnitOffset &addOrThrow(const IntegerUnitOffset other)

Add another offset.

Throws:

OverflowError – if the result would exceed minimum() or maximum().

inline constexpr IntegerUnitOffset addedOrThrow(const IntegerUnitOffset other) const

Create a new offset by adding another offset to it.

Throws:

OverflowError – if the result would exceed minimum() or maximum().

inline constexpr bool wouldSubtractSaturate(const IntegerUnitOffset other) const noexcept

Test if subtracting another offset would saturate this offset.

inline IntegerUnitOffset &subtract(const IntegerUnitOffset other) noexcept

Subtract another offset, saturating at minimum() or maximum().

inline constexpr IntegerUnitOffset subtracted(const IntegerUnitOffset other) const noexcept

Create a new offset by subtracting another offset from it.

inline IntegerUnitOffset &subtractOrThrow(const IntegerUnitOffset other)

Subtract another offset.

Throws:

OverflowError – if the result would exceed minimum() or maximum().

inline constexpr IntegerUnitOffset subtractedOrThrow(const IntegerUnitOffset other) const

Create a new offset by subtracting another offset from it.

Throws:

OverflowError – if the result would exceed minimum() or maximum().

template<math::AnyIntegerType T>
inline IntegerUnitOffset &multiply(T scalar) noexcept

Multiply this offset by a signed scalar with saturation.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitOffset multiplied(T scalar) const noexcept

Create a new offset by multiplying this offset with a signed scalar.

template<math::AnyIntegerType T>
inline IntegerUnitOffset &divide(T scalar) noexcept

Divide this offset by a signed scalar.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitOffset divided(T scalar) const noexcept

Create a new offset by dividing this offset by a signed scalar.

template<math::AnyIntegerType T>
inline IntegerUnitOffset &applyModulo(T scalar) noexcept

Apply modulo with a signed scalar.

template<math::AnyIntegerType T>
inline constexpr IntegerUnitOffset modulo(T scalar) const noexcept

Calculate the modulo of this offset and a signed scalar.

inline constexpr IntegerUnitOffset negated() const noexcept

Create a new offset with the sign inverted, saturating the minimum value to maximum().

Public Static Functions

static inline constexpr IntegerUnitOffset zero() noexcept

Return the zero offset.

static inline constexpr IntegerUnitOffset one() noexcept

Return the offset one.

static inline constexpr IntegerUnitOffset minusOne() noexcept

Return the offset negative one.

static inline constexpr IntegerUnitOffset minimum() noexcept

Return the smallest offset.

static inline constexpr IntegerUnitOffset maximum() noexcept

Return the largest offset.

Public Static Attributes

static constexpr Value cRawMinimum = std::numeric_limits<Value>::min()

The smallest raw offset value.

static constexpr Value cRawMaximum = std::numeric_limits<Value>::max()

The largest raw offset value.

template<impl::ValidIntegerUnit tIntegerUnit>
class IntegerUnitRange

A range with a unit tag.

A range is represented as a start index and a length. The start index may be noIndex() only to represent an invalid or absent range; contains() and isWithin() return false for such ranges.

Template Parameters:

tIntegerUnit – The unit tag for this range.

Public Types

using Unit = tIntegerUnit

The unit type.

using Index = IntegerUnitIndex<tIntegerUnit>

The matching index type.

using Length = IntegerUnitAmount<tIntegerUnit>

The matching length type.

using Offset = IntegerUnitOffset<tIntegerUnit>

The matching offset type.

Public Functions

constexpr IntegerUnitRange() noexcept = default

Create an empty range starting at zero.

inline constexpr IntegerUnitRange(Index index, Length length) noexcept

Create a range from a start index and length.

inline constexpr IntegerUnitRange(Index begin, Index end) noexcept

Create a range from a beginning and end index.

The end index must be greater than or equal to the start index. If the end index is “no index”, the length of the range is infinite. The end index is considered one after the last unit.

Parameters:
  • begin – The index that marks the first element.

  • end – The index after the last element, or no-index for infinite length.

inline constexpr std::strong_ordering operator<=>(const IntegerUnitRange &other) const noexcept

Compare this range with another range.

inline constexpr IntegerUnitRange operator+(const Offset offset) const noexcept

Move this range by an offset and return the saturated result.

inline IntegerUnitRange &operator+=(const Offset offset) noexcept

Move this range by an offset with saturation.

inline constexpr IntegerUnitRange operator-(const Offset offset) const noexcept

Move this range by the negated offset and return the saturated result.

inline IntegerUnitRange &operator-=(const Offset offset) noexcept

Move this range by the negated offset with saturation.

inline constexpr bool isValid() const noexcept

Test if this range starts at a valid index.

inline constexpr bool isEmpty() const noexcept

Test if this range is empty.

inline constexpr bool isInfinite() const noexcept

Test if this range has an infinite length.

inline constexpr bool contains(const Index index) const noexcept

Test if this range contains the given index.

inline constexpr bool isWithin(const Length bounds) const noexcept

Test if this whole range fits within the given bounds length.

inline constexpr IntegerUnitRange clampedTo(const Length bounds) const noexcept

Return this range clamped to a sequence with the given bounds length.

Invalid ranges stay invalid. Ranges starting beyond the bounds become empty at the end of the bounds.

inline constexpr Index index() const noexcept

Get the start index of this range.

inline constexpr Length length() const noexcept

Get the length of this range.

inline constexpr void setIndex(Index index) noexcept

Set the start index of this range.

inline constexpr void setLength(Length length) noexcept

Set the length of this range.

inline constexpr Index endIndex() const noexcept

Get the first index after this range.

If the range is invalid, infinite, or exceeds the representable index space, this returns Index::noIndex().

inline IntegerUnitRange &advance(const Length length) noexcept

Advance the start index by a non-negative length.

inline IntegerUnitRange &retreat(const Length length) noexcept

Retreat the start index by a non-negative length.

inline IntegerUnitRange &move(const Offset offset) noexcept

Move the start index by a signed offset.

inline constexpr IntegerUnitRange advanced(const Length length) const noexcept

Create a new range with the start index advanced by a non-negative length.

inline constexpr IntegerUnitRange retreated(const Length length) const noexcept

Create a new range with the start index retreated by a non-negative length.

inline constexpr IntegerUnitRange moved(const Offset offset) const noexcept

Create a new range with the start index moved by a signed offset.

inline constexpr IntegerUnitRange withOrigin(const Index origin) const noexcept

Create a new range by interpreting this range as relative to the given origin index.

template<typename Fn>
inline util::LoopResult forEach(Fn &&loopFn) const

Call a function for each index in this range.

Raw index values are incremented internally, avoiding saturation checks for every step.

Parameters:

loopFn – The function to call with each index. It may return void or util::LoopStatus.

Returns:

The result of the loop.

Public Static Functions

static inline constexpr IntegerUnitRange empty() noexcept

Return an empty range starting at zero.

static inline constexpr IntegerUnitRange emptyAt(Index index) noexcept

Return an empty range starting at the given index.

static inline constexpr IntegerUnitRange all() noexcept

Return a range starting at zero with infinite length.

static inline constexpr IntegerUnitRange noRange() noexcept

Return an invalid or absent range.

static inline constexpr IntegerUnitRange fromLength(const Length length) noexcept

Return a range starting at zero with a given length.

Parameters:

length – The length to use for the range.

static inline constexpr IntegerUnitRange fromSizeT(const std::size_t length) noexcept

Return a range starting at zero with a length from std::size_t.

The length saturates at the maximum value of Length.

Parameters:

length – The length to use for the range.

static inline constexpr IntegerUnitRange fromSizeTOrThrow(const std::size_t length)

Return a range starting at zero with a length from std::size_t.

Parameters:

length – The length to use for the range.

Throws:

err::OverflowError – if the length is too large to represent.

Friends

inline friend void swap(IntegerUnitRange &first, IntegerUnitRange &second) noexcept

Swap two ranges.

using erbsland::unit::ItemCount = IntegerUnitAmount<ItemUnit>

A non-negative number of items.

using erbsland::unit::ItemIndex = IntegerUnitIndex<ItemUnit>

A zero-based item index.

using erbsland::unit::ItemOffset = IntegerUnitOffset<ItemUnit>

A signed offset in item units.

using erbsland::unit::ItemRange = IntegerUnitRange<ItemUnit>

A half-open range of items.

struct ItemUnit : public erbsland::unit::IntegerUnit

The integer unit for list item positions and counts.

using erbsland::unit::LineCount = IntegerUnitAmount<LineUnit>

A source code line count.

using erbsland::unit::LineIndex = IntegerUnitIndex<LineUnit>

A zero-based source code line index.

using erbsland::unit::LineOffset = IntegerUnitOffset<LineUnit>

A signed source code line offset.

using erbsland::unit::LineRange = IntegerUnitRange<LineUnit>

A range of source code lines.

struct LineUnit : public erbsland::unit::IntegerUnit

The integer unit for source code line types.

Public Types

using IndexType = uint32_t

The unsigned integer type for indexes.

using AmountType = uint32_t

The unsigned integer type for amounts.

using OffsetType = int32_t

The signed integer type for offsets.

using erbsland::unit::U16DataIndex = IntegerUnitIndex<U16DataUnit>

An index for UTF-16 data.

using erbsland::unit::U16DataLength = IntegerUnitAmount<U16DataUnit>

A length for UTF-16 data.

using erbsland::unit::U16DataOffset = IntegerUnitOffset<U16DataUnit>

An offset for UTF-16 data.

using erbsland::unit::U16DataRange = IntegerUnitRange<U16DataUnit>

A range for UTF-16 data.

struct U16DataUnit : public erbsland::unit::IntegerUnit

The integer unit for char16_t-based data types.

Public Types

using IndexType = uint32_t

The unsigned integer type for indexes.

using AmountType = uint32_t

The unsigned integer type for amounts.

using OffsetType = int32_t

The signed integer type for offsets.

class Version

A version consisting of major, minor, revision, and build number.

The default version is 0.0.0.0. Version comparison is lexicographic by all four parts unless a precision is supplied. With a precision, all less-significant parts are ignored.

Public Types

using Value = uint16_t

The raw unsigned integer type used for each version part.

Public Functions

constexpr Version() noexcept = default

Create version 0.0.0.0.

inline explicit constexpr Version(Value major, Value minor = 0U, Value revision = 0U, Value build = 0U) noexcept

Create a version from raw values.

template<impl::VersionComponentArgument... tArguments>
inline explicit constexpr Version(tArguments... arguments) noexcept

Create a version from typed version parts in any order.

inline constexpr std::strong_ordering operator<=>(const Version &other) const noexcept

Compare this version with another version at full precision.

constexpr auto inRange(const VersionRange &range, VersionPart precision = VersionPart::Build) const noexcept -> bool

Test if this version is in the given range using the selected precision.

Test whether this version is contained in a range at the given precision.

inline constexpr Major major() const noexcept

Get the major version number.

inline constexpr void setMajor(Major major) noexcept

Set the major version number.

inline constexpr Minor minor() const noexcept

Get the minor version number.

inline constexpr void setMinor(Minor minor) noexcept

Set the minor version number.

inline constexpr Revision revision() const noexcept

Get the revision version number.

inline constexpr void setRevision(Revision revision) noexcept

Set the revision version number.

inline constexpr BuildNumber build() const noexcept

Get the build version number.

inline constexpr void setBuild(BuildNumber build) noexcept

Set the build version number.

inline constexpr std::strong_ordering compare(const Version &other, VersionPart precision) const noexcept

Compare this version with another version using the given precision.

text::String toString(VersionPart precision = VersionPart::Revision) const

Convert this version into dotted decimal text.

Parameters:

precision – The least significant version part to include.

Returns:

The version text.

inline constexpr uint64_t toNumber() const noexcept

Convert this version into a packed 64-bit number.

Public Static Functions

static inline constexpr Version fromNumber(uint64_t value) noexcept

Create a version from a packed 64-bit number.

Friends

inline friend constexpr void swap(Version &first, Version &second) noexcept

Swap two versions.

Warning

doxygenstruct: Cannot find class “std::hash” in doxygen xml output for project “erbsland-core” from directory: /home/runner/work/erbsland-core/erbsland-core/_build/breathe/doxygen/erbsland-core/xml

enum class erbsland::unit::VersionPart : uint8_t

The part of a version number.

The order of the values follows their significance in a version.

Values:

enumerator Major

The major version part.

enumerator Minor

The minor version part.

enumerator Revision

The revision version part.

enumerator Build

The build version part.

class VersionRange

An inclusive range of versions.

A version range may have no minimum, no maximum, or neither bound. Existing bounds are inclusive. Precision-limited containment uses the same comparison rules as Version::compare().

Public Functions

constexpr VersionRange() noexcept = default

Create an open-ended range.

inline constexpr VersionRange(std::optional<Version> minimum, std::optional<Version> maximum) noexcept

Create a range from optional inclusive bounds.

inline constexpr std::strong_ordering operator<=>(const VersionRange &other) const noexcept

Compare this range with another range.

inline constexpr bool hasMinimum() const noexcept

Test if this range has a minimum bound.

inline constexpr bool hasMaximum() const noexcept

Test if this range has a maximum bound.

inline constexpr bool isEmpty(VersionPart precision = VersionPart::Build) const noexcept

Test if this range is empty using the selected precision.

inline constexpr auto contains(const Version &version, VersionPart precision = VersionPart::Build) const noexcept -> bool

Test if this range contains the given version using the selected precision.

inline constexpr std::optional<Version> minimum() const noexcept

Get the inclusive minimum bound.

inline constexpr void setMinimum(const std::optional<Version> minimum) noexcept

Set the inclusive minimum bound.

inline constexpr std::optional<Version> maximum() const noexcept

Get the inclusive maximum bound.

inline constexpr void setMaximum(const std::optional<Version> maximum) noexcept

Set the inclusive maximum bound.

Public Static Functions

static inline constexpr VersionRange all() noexcept

Return a range without bounds.

static inline constexpr VersionRange atLeast(Version minimum) noexcept

Return a range with only an inclusive minimum bound.

static inline constexpr VersionRange atMost(Version maximum) noexcept

Return a range with only an inclusive maximum bound.

static inline constexpr VersionRange between(Version minimum, Version maximum) noexcept

Return a range with inclusive minimum and maximum bounds.

static inline constexpr VersionRange exact(Version version) noexcept

Return a range that contains exactly one version.

Friends

inline friend constexpr void swap(VersionRange &first, VersionRange &second) noexcept

Swap two version ranges.

struct VersionUnit : public erbsland::unit::IntegerUnit

The integer unit for version components.

Subclassed by erbsland::unit::BuildNumberUnit, erbsland::unit::MajorUnit, erbsland::unit::MinorUnit, erbsland::unit::RevisionUnit

Public Types

using IndexType = uint16_t

The unsigned integer type for version parts.

using AmountType = uint16_t

The unsigned integer type for version-part movements.

using OffsetType = int32_t

The signed integer type for version-part offsets.

Public Static Attributes

static constexpr auto cHasNoIndex = false

Version parts use the full 16-bit range.

struct MajorUnit : public erbsland::unit::VersionUnit

The integer unit for major version components.

Public Static Attributes

static constexpr auto cPart = VersionPart::Major

The version part represented by this unit.

struct MinorUnit : public erbsland::unit::VersionUnit

The integer unit for minor version components.

Public Static Attributes

static constexpr auto cPart = VersionPart::Minor

The version part represented by this unit.

struct RevisionUnit : public erbsland::unit::VersionUnit

The integer unit for revision version components.

Public Static Attributes

static constexpr auto cPart = VersionPart::Revision

The version part represented by this unit.

struct BuildNumberUnit : public erbsland::unit::VersionUnit

The integer unit for build-number version components.

Public Static Attributes

static constexpr auto cPart = VersionPart::Build

The version part represented by this unit.

using erbsland::unit::Major = IntegerUnitIndex<MajorUnit>

A major version number.

using erbsland::unit::Minor = IntegerUnitIndex<MinorUnit>

A minor version number.

using erbsland::unit::Revision = IntegerUnitIndex<RevisionUnit>

A revision version number.

using erbsland::unit::BuildNumber = IntegerUnitIndex<BuildNumberUnit>

A build version number.