A collection of common types to plug holes in pre-C++20 versions. This library provides the following things:
kstd::Boxfor encapsulating references as pointerskstd::NonZerofor integers and pointerskstd::Optionas astd::optionalreplacement with reference support and NonZero optimizationskstd::OutPtras suggested by C++26kstd::Packfor emulating first-class type support of parameter packskstd::RelativePtrfor defining relative pointerskstd::Resultresult type with support forvoidand referenceskstd::Sliceas a pre-C++20 replacement forstd::spankstd::SourceLocationas a pre-C++20 replacement forstd::source_locationkstd::Tupleas a replacement forstd::tuplewith support for references and easy concatinationkstd::Voidtype for denoting empty states instd::variantand as a dummy typekstd::StaticVectoras an option for a lightweight small vector implementation.kstd::transmutefunction as a replacement forstd::bitcast- Cross-platform unicode conversion API with support for UTF-8/16/32
- Safe allocation API which wraps around
new/make_unique/make_sharedand provides results - Non-IO-stream print API based on {fmt}
- Copy/move implementation macros for default/delete implementation
- Hash API for hashing more than one value and for combining hashes
- Readable macro definitions for detecting the C++ version (C++11/14/17/20/23)
- Type-safe cross-platform wrapper for the C standard library
- Rust-like type definitions for
cstdinttypes and atomics (i8,f32etc.) - Assertions with source locations (source traces)
- Bitflag types (enum classes with bitwise operators using macros)
kstd-core provides tight integration with C++'s builtin STL to turn kstd-core's specialized types into drop-in replacements for their std-counterparts.
kstd::Resultsupports bidirectional conversion from/tostd::expectedin C++23 and upkstd::Optionsupports bidirectional conversion from/tostd::optionalin C++20 and upkstd::Slicesupports bidirectional conversion from/tostd::spanin C++20 and upkstd::Tuplesupports bidirectional conversion from/tostd::tuple
In order to build kstd-core with unit tests, you can simply use CMake as follows after cloning the repository:
cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug -DKSTD_CORE_BUILD_TESTS=ON
cmake --build cmake-build-debugThis will produce an executable kstd-core-tests(.exe) inside of the cmake-build-debug directory.
You can directly run this to invoke the Google Test suite.