Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Semantic Versioning for modern C++

License

NotificationsYou must be signed in to change notification settings

Neargye/semver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Github releasesVcpkg packageConan packageLicense

C++ library compare and manipulate versions are available as extensions to the<major>.<minor>.<patch>-<prerelease_tag>+<build_metadata> format complying withSemantic Versioning 2.0.0

  • Parse

    semver::version v1;if (semver::parse("1.4.3", v1)) {constint patch = v1.patch();// 3// do something...}semver::version v2;if (semver::parse("1.2.4-alpha.10")) {const std::string prerelease_tag = v2.prerelease_tag()// alpha.10// do something...}
  • Сomparison

    assert(v1 != v2);assert(v1 > v2);assert(v1 >= v2);assert(v2 < v1);assert(v2 <= v1);
  • Validate

    constbool result = semver::valid("1.2.3-alpha+build");assert(result);
  • Range matching

    semver::range_set range;if (semver::parse(">=1.0.0 <2.0.0 || >3.2.1", range)) {  semver::version version;if (semver::parse("1.2.3", version)) {assert(range.contains(version));  }}

Check theexamples folder to see more various usage examples

Integration

You should add required filesemver.hpp.

If you are usingvcpkg on your project for external dependencies, then you can use theneargye-semver.

If you are usingConan to manage your dependencies, merely addneargye-semver/x.y.z to your conan's requires, wherex.y.z is the release version you want to use.

Alternatively, you can use something likeCPM which is based on CMake'sFetch_Content module.

CPMAddPackage(NAME semver    GITHUB_REPOSITORY Neargye/semver    GIT_TAG x.y.z# Where `x.y.z` is the release version you want to use.)

Compiler compatibility

  • Clang/LLVM >= 5
  • MSVC++ >= 14.11 / Visual Studio >= 2017
  • Xcode >= 10
  • GCC >= 7

Licensed under theMIT License


[8]ページ先頭

©2009-2025 Movatter.jp