Ktl
Collection of ktl header libraries - small C++20 wrapper utilities
Install / Use
/learn @karnkaul/KtlREADME
KTL
A lightweight set of utility headers written in C++20.
Usage
Requirements
- CMake
- C++20 compiler (and stdlib)
Steps
- Clone repo to appropriate subdirectory, say
ktl - Add library to project via:
add_subdirectory(ktl)andtarget_link_libraries(foo ktl::ktl) - Use desired headers via
#include <ktl/header.hpp>
Headers
async/async_queue.hpp
FIFO queue with thread safe "sleepy" API.
Features:
- Policy customization
- Multiple queues
- Thread-safe push-and-notify (to any desired queue)
- Thread-safe wait-and-pop (from first of any desired queues)
- Clear all queues and return residue
- Deactivate all queues (as secondary wait condition)
async/kfuture.hpp
Async operation / shared state wrappers, with .then() support.
async/kfunction.hpp
Callable wrapper that cannot be copied, only moved. Used in kpackaged_task and kfuture.
async/kthread.hpp
std::thread wrapper that joins on destruction / move, and supports stop_t tokens.
async/kmutex.hpp
Basic and strict wrappers for a T and its (mutable) mutex, stdlib RAII lock types.
async/shared_kmutex.hpp
Aliases of tmutex with std::shared_mutex.
enum_flags/enum_flags.hpp
Wrapper around an integral type used as bit flags.
enum_flags/bitflags.hpp
Free functions for working with integral bit flags.
byte_array.hpp
Lightweight, resizeable wrapper over std::unique_ptr<std::byte[]>.
debug_trap.hpp
x86/x64 debugger trap/break.
delegate.hpp
Tagged observer store with RAII signals.
either.hpp
RAII union of two types.
enumerate.hpp
Wrapper for indexed iteration over ranges represented by pairs of iterators.
expected.hpp
Union of expected and unexpected types; uses either.hpp.
fifo_map.hpp
First-In First-Out map.
fixed_any.hpp
Fixed-size type erased storage.
fixed_vector.hpp
Fixed-size vector-like container using bytearray as storage.
hash_table.hpp
Lightweight hash-table with open addressing and reduced iterator stability.
kformat.hpp
Lightweight fmt-like std::string interpolation with basic formatting support.
kunique_ptr.hpp
Lightweight unique pointer to heap-allocated Type*.
kversion.hpp
Semantic version.
monotonic_map.hpp
Wrapper over an (un)ordered map that associates each T with a unique RAII handle which can be used to unregister the instance.
n_tree.hpp
Models a "forward" N-tree (no parent link) via std::forward_list.
not_null.hpp
Wrapper for raw / smart pointers that is restricted from being null.
ring_buffer.hpp
Rotating ring-buffer using contiguous storage (std::vector<T> by default). Overwrites on overflow.
ring_counter.hpp
Fixed-size rotating integral counter. Supports increment/decrement.
Contributing
Pull/merge requests are welcome.
Related Skills
node-connect
342.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
85.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
342.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
