commons 0.1.5
Header-only C++23 library of common/shared types for the C++ libraries
Loading...
Searching...
No Matches
comms::SemVer Struct Reference

A semantic version: major.minor.patch with optional prerelease/build. More...

#include <semver.hpp>

Public Member Functions

std::string to_string () const
 The canonical string: major.minor.patch, then -prerelease if set, then +build if set.
 
std::strong_ordering operator<=> (const SemVer &o) const
 Total order over major, minor, patch, then prerelease per §11.
 
bool operator== (const SemVer &o) const
 Equality consistent with <=> (so it likewise ignores build metadata).
 

Static Public Member Functions

static std::optional< SemVerparse (std::string_view s)
 Non-throwing parse.
 

Public Attributes

std::string prerelease
 Part after '-', before '+' (no leading '-').
 
std::string build
 Part after '+' (no leading '+').
 

Detailed Description

A semantic version: major.minor.patch with optional prerelease/build.

Member Function Documentation

◆ operator<=>()

std::strong_ordering comms::SemVer::operator<=> ( const SemVer o) const
inline

Total order over major, minor, patch, then prerelease per §11.

Build metadata is excluded (§10).

◆ operator==()

bool comms::SemVer::operator== ( const SemVer o) const
inline

Equality consistent with <=> (so it likewise ignores build metadata).

Cannot be defaulted: the custom <=> excludes build.

◆ parse()

static std::optional< SemVer > comms::SemVer::parse ( std::string_view  s)
inlinestatic

Non-throwing parse.

Accepts an optional leading v/V, a leniently partial numeric core ("1", "1.2", "1.2.3"), and validated -prerelease / +build suffixes. Returns std::nullopt on any malformed input.


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