_____ _ _
/ ____| | | (_)
| (___ ___ _ __ ___ __ _ _ __ | |_ _ ___
\___ \ / _ \ '_ ` _ \ / _` | '_ \| __| |/ __|
____) | __/ | | | | | (_| | | | | |_| | (__
|_____/ \___|_| |_| |_|\__,_|_| |_|\__|_|\___|
__ __ _ _ _____
\ \ / / (_) (_) / ____|_ _
\ \ / /__ _ __ ___ _ ___ _ __ _ _ __ __ _ | | _| |_ _| |_
\ \/ / _ \ '__/ __| |/ _ \| '_ \| | '_ \ / _` | | | |_ _|_ _|
\ / __/ | \__ \ | (_) | | | | | | | | (_| | | |____|_| |_|
\/ \___|_| |___/_|\___/|_| |_|_|_| |_|\__, | \_____|
__/ |
|___/
C++ library compare and manipulate versions are available as extensions to the <major>.<minor>.<patch>-<prerelease_type>.<prerelease_number>
format complying with Semantic Versioning 2.0.0
- C++17
- Header-only
- Dependency-free
- Constexpr comparison: <, <=, ==, !=, > >=
- Constexpr from string
- To String
- Create
constexpr version v1 = version{1, 2, 3, prerelease::rc, 4};
constexpr version v2 = v1;
- Сomparison
constexpr semver::version v1{1, 4, 3};
constexpr semver::version v2{1, 2, 4, semver::prerelease::alpha, 10};
static_assert(v1 != v2);
static_assert(v1 > v2);
static_assert(v1 >= v2);
static_assert(v2 < v1);
static_assert(v2 <= v1);
- To string
constexpr semver::version v{1, 2, 3, prerelease::rc, 4};
auto s = v.to_string(); // "1.2.3-rc.4"
- From string
constexpr version v1("1.2.3-rc.4");
constexpr version v2 = "1.2.3-rc.4"_version;
You should add required file semver.hpp.
- Clang/LLVM >= 5
- Visual C++ >= 15.3 / Visual Studio >= 2017
- Xcode >= 10.2
- GCC >= 7