Foundry is a cross-platform C++ utility library that collects small, self-contained tools commonly needed across projects, so they don't have to be rewritten each time. It focuses on a handful of dependency-light building blocks with clear, minimal APIs.
Built with C++17 as its baseline standard, Foundry targets Linux, macOS, and Windows, and each utility can be adopted on its own without pulling in the rest of the library.
- Scope Guard - Cleanup code guaranteed to run on scope exit, early return, or exception.
scope_guard_example.cpp - Run Once / Run At Exit - One-shot execution per call site and lambda-based
atexitregistration with LIFO ordering.run_once_example.cpp - Flags - Type-safe bitmask container for
enum classvalues with compile-time mixing prevention.flags_example.cpp - Result - Exceptionless, type-safe
Result<T, E>monad for flexible error handling and chaining.result_example.cpp - Semantic Version - Lightweight parser and representation for Semantic Versioning.
semver_example.cpp - Platform Paths - Runtime resolution of working directory, executable path, and temp directory as
std::filesystem::path.paths_example.cpp
Foundry can be integrated into a CMake project using either FetchContent or add_subdirectory().
include(FetchContent)
FetchContent_Declare(
foundry
GIT_REPOSITORY https://github.com/DMsuDev/foundry.git
GIT_TAG # pin to a release tag or commit hash
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(foundry)
target_link_libraries(my_app PRIVATE Foundry::Foundry)add_subdirectory(vendor/foundry)
target_link_libraries(my_app PRIVATE Foundry::Foundry)Foundry is licensed under the MIT License.
See LICENSE for more information.