Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::semantic_version Class Reference

A class representing semantic versions (https://semver.org/). Does not include build metadata or prerelease comparisons. More...

Inheritance diagram for arene::base::semantic_version:
Inheritance graph

Public Member Functions

constexpr semantic_version () noexcept
 Default ctor, creates a semver of all 0's.
 
constexpr semantic_version (std::uint16_t const major_version, std::uint16_t const minor_version=0U, std::uint32_t const patch_version=0U) noexcept
 Constructs a semantic_version with the given major, minor, and patch version.
 
ARENE_NODISCARD constexpr auto is_unstable () const noexcept -> bool
 Tests whether this semantic version represents an "unstable" entity, which is one with a major of 0.
 
ARENE_NODISCARD constexpr auto major () const noexcept -> std::uint16_t
 Get the major version component.
 
ARENE_NODISCARD constexpr auto minor () const noexcept -> std::uint16_t
 Get the minor version component.
 
ARENE_NODISCARD constexpr auto patch () const noexcept -> std::uint32_t
 Get the patch version component.
 

Static Public Member Functions

static ARENE_NODISCARD constexpr auto three_way_compare (semantic_version const left, semantic_version const right) noexcept -> arene::base::strong_ordering
 Implements a strong lexicographic sort order based on [major, minor, path], in that order.
 

Detailed Description

A class representing semantic versions (https://semver.org/). Does not include build metadata or prerelease comparisons.

Remarks
Pre-releases and Build metadata are effectively (ASCII) strings, and therefore do not fit into compile-time computation. Should there be significant enough demand, an extended_semantic_version with prerelease and build metadata can be considered, but this class does not retain or track such information.

Constructor & Destructor Documentation

◆ semantic_version() [1/2]

arene::base::semantic_version::semantic_version ( )
inlineconstexprnoexcept

Default ctor, creates a semver of all 0's.

Postcondition
major() == 0
minor() == 0
patch() == 0

◆ semantic_version() [2/2]

arene::base::semantic_version::semantic_version ( std::uint16_t const major_version,
std::uint16_t const minor_version = 0U,
std::uint32_t const patch_version = 0U )
inlineexplicitconstexprnoexcept

Constructs a semantic_version with the given major, minor, and patch version.

Parameters
major_versionThe major version number.
minor_versionThe minor version number.
patch_versionThe patch version number.
Postcondition
major() == major_version
minor() == minor_version
patch() == patch_version

Member Function Documentation

◆ is_unstable()

ARENE_NODISCARD constexpr auto arene::base::semantic_version::is_unstable ( ) const -> bool
inlineconstexprnoexcept

Tests whether this semantic version represents an "unstable" entity, which is one with a major of 0.

Returns
true iff major() == 0
false otherwise

◆ major()

ARENE_NODISCARD constexpr auto arene::base::semantic_version::major ( ) const -> std::uint16_t
inlineconstexprnoexcept

Get the major version component.

Returns
major version number

◆ minor()

ARENE_NODISCARD constexpr auto arene::base::semantic_version::minor ( ) const -> std::uint16_t
inlineconstexprnoexcept

Get the minor version component.

Returns
minor version number

◆ patch()

ARENE_NODISCARD constexpr auto arene::base::semantic_version::patch ( ) const -> std::uint32_t
inlineconstexprnoexcept

Get the patch version component.

Returns
patch version number

◆ three_way_compare()

ARENE_NODISCARD constexpr auto arene::base::semantic_version::three_way_compare ( semantic_version const left,
semantic_version const right ) -> arene::base::strong_ordering
staticconstexprnoexcept

Implements a strong lexicographic sort order based on [major, minor, path], in that order.

Parameters
leftThe left hand side of the comparison.
rightThe right hand side of the comparison.
Returns
strong_ordering::less if lhs lexicographically precedes rhs.
strong_ordering::equal if lhs and rhs are equal across major, minor, and patch.
strong_ordering::less if lhs lexicographically follows rhs.

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