MSL (Marty Support Library) is a header-only C++20 utility library focused on practical helpers with minimal integration friction.
| Header | Purpose |
|---|---|
msl/assert.h |
Assert helpers and test exceptions (check_assert, test_assert, test_error). |
msl/bench.h |
Lightweight benchmarking/evaluation helpers. |
msl/cast.h |
Truncation/integral conversion helpers with checked paths. |
msl/file_ptr.h |
RAII wrapper around FILE* with read/write helpers. |
msl/macro.h |
Public MSL_FOR_* loop and test macros. |
msl/pool.h |
Thread-safe shared object pool (shared_pool<T>). |
msl/ptr.h |
Pointer ownership wrappers (scoped_shared_ptr, no_owner, observer_ptr). |
msl/random.h |
Random generators, number utilities, and container sampling. |
msl/range.h |
Range/xrange and indexed iteration helpers. |
msl/traits.h |
Type traits for contiguous/raw template constraints (msl::traits::*). |
msl/utils.h |
String and container utility helpers. |
msl/util.h |
Compatibility forwarding header to msl/utils.h. |
msl/legacy.h |
Opt-in legacy compatibility helpers (minmax, bind/random-shuffle/mem_fun wrappers). |
msl/msl.h |
Aggregate include for all MSL headers. |
Copy include/msl/ into your include path and use:
#include <msl/msl.h>include(FetchContent)
FetchContent_Declare(
MSL
GIT_REPOSITORY https://github.com/martysama0134/MSL.git
GIT_TAG main
)
FetchContent_MakeAvailable(MSL)
target_link_libraries(your_target PRIVATE msl::msl)Build/install:
cmake -S . -B build/install -DMSL_BUILD_TESTS=OFF
cmake --build build/install
cmake --install build/install --prefix /your/prefixConsume:
find_package(MSL CONFIG REQUIRED)
target_link_libraries(your_target PRIVATE msl::msl)include/msl/: public header-only library.tests/: deterministic CI regression tests and header smoke builds.examples/: compile-verified example programs (optional build viaMSL_BUILD_EXAMPLES).docs/: compatibility, migration, and release validation docs.legacy/vs/: legacy Visual Studio solution/project and demo-heavy test assets.
| Platform | Compiler/toolchain | Status |
|---|---|---|
| Windows | Visual Studio 2022 (MSVC v143) | First-class |
| Linux | GCC 14+ (libstdc++) | First-class |
| Linux | Clang 19+ (libstdc++14+ or libc++19+) | First-class |
| FreeBSD 14/15 | Default cc / c++ (Clang 18/19) |
Release-gated manual validation |
MSL targets C++20 and requires std::format plus std::ranges as baseline dependencies in v4.0+.
Current CI quality gates:
windows-msvc(blocking)linux-gcc14-libstdcxx(blocking)linux-clang19-libstdcxx(blocking)linux-clang19-libcxx(blocking)linux-clang-asan-ubsan(blocking)alpine-clang(non-blocking)
#include <msl/utils.h>
#include <iostream>
int main() {
auto parts = msl::string_split("alpha::beta::gamma", "::");
std::cout << parts.size() << "\n"; // 3
}#include <msl/cast.h>
int main() {
auto v = msl::integral_cast<int>(42.0); // ok
// msl::integral_cast<int>(42.5); // throws msl::truncate_error
}#include <msl/pool.h>
struct Obj { int value{}; };
int main() {
auto pool = msl::shared_pool<Obj>::create();
auto h = pool->acquire();
h->value = 123;
}file_ptr:open(std::string_view, ...)now opens through owned null-terminated strings.- reopening via
open(...)first closes any currently owned file handle. write(fmt, args...)keeps legacyprintfformatting compatibility.write_fmt(fmt, args...)provides C++20std::formatformatting.- byte-oriented write helpers return bytes written.
string_read(char[], n)is defined forn == 0(no-op) and always null-terminates forn > 0.
cast:- checked floating-to-integral paths reject
NaN,inf, out-of-range values, and fractional values forintegral_cast.
- checked floating-to-integral paths reject
shared_pool:shared_pool<T>::handle::get()now correctly returnsT*.shared_poolremains thread-safe via internal mutex-protected operations.
traits:msl::traits::is_contiguous_v<T>andmsl::traits::is_raw_v<T>are available for template routing and raw-write constraints.
utils:to_lower_in_place/to_lowerare intentionally ASCII/language-neutral right now.- Unicode-aware lowercase helper(s) may be added later with distinct API names.
format_grouped_number(value, separator)provides simple digit grouping for integral values.
MSL_FOR_*macros are supported public API.legacy:<msl/legacy.h>is an explicit opt-in compatibility header.- legacy helpers are exposed in
mslnamespace and are not included by<msl/msl.h>. - legacy helpers do not extend
namespace std.
Use <msl/legacy.h> only for compatibility migrations. It is intentionally separate from the default aggregate include to keep modern usage lean.
#include <msl/legacy.h>
int main() {
const auto v = msl::minmax(10, 42, 0); // auto-swaps bounds, returns 10
}Presets:
cmake --preset dev
cmake --build --preset dev
ctest --preset devShell helpers:
./test_build.sh
./test_run.shCI runs deterministic tests from tests/ only. Legacy demo-heavy test sources remain in legacy/vs/msl/test_*.cpp for local/manual use.
Configure/build examples:
cmake -S . -B build/examples -DMSL_BUILD_TESTS=ON -DMSL_BUILD_EXAMPLES=ON
cmake --build build/examplesExample executables:
msl_example_string_splitmsl_example_safe_castmsl_example_shared_poolmsl_example_file_ptr_io
- Current release target:
v4.0.0. - Changelog: CHANGELOG.md
- Migration notes: docs/MIGRATION_v4.md
- Compatibility policy: docs/COMPATIBILITY.md
- Legacy API map: docs/LEGACY_API_MAP.md
- Release validation gate: docs/RELEASE_VALIDATION.md
- Legacy Visual Studio solution:
legacy/vs/msl_tests.sln
MSL is distributed under the MIT License. See LICENSE.