A collection of common types to plug holes in pre-C++20 versions. This library provides the following things:
kstd::Box
for encapsulating references as pointerskstd::NonZero
for integers and pointerskstd::Option
as astd::optional
replacement with reference support and NonZero optimizationskstd::OutPtr
as suggested by C++26kstd::Pack
for emulating first-class type support of parameter packskstd::RelativePtr
for defining relative pointerskstd::Result
result type with support forvoid
and referenceskstd::Slice
as a pre-C++20 replacement forstd::span
kstd::SourceLocation
as a pre-C++20 replacement forstd::source_location
kstd::Tuple
as a replacement forstd::tuple
with support for references and easy concatinationkstd::Void
type for denoting empty states instd::variant
and as a dummy typekstd::StaticVector
as an option for a lightweight small vector implementation.kstd::transmute
function 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_shared
and 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
cstdint
types and atomics (i8
,f32
etc.) - 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::Result
supports bidirectional conversion from/tostd::expected
in C++23 and upkstd::Option
supports bidirectional conversion from/tostd::optional
in C++20 and upkstd::Slice
supports bidirectional conversion from/tostd::span
in C++20 and upkstd::Tuple
supports 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-debug
This 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.