A collection of small single-header C++ libraries similar to or extending the C++ standard library. See below for a list.
itlib was forked from chobo-shl which is no longer supported. New libraries and updates to the existing ones are added here.
Building with GitHub actions on Windows with MSVC, Ubuntu with GCC, and macOS with clang. Debug and Release. With address sanitizer and thread sanitizer where applicable.
Every .hpp file in include/itlib is a standalone library and has no dependencies other than the standard lib.
Documentation is provided in comments at the top of each file.
In the list below each library shows its minimum supported C++ standard and has icons for other standards if additional features are available for them.
| Library | Description | 
|---|---|
| any.hpp | An alternative implementation of C++17's std::anywithout the limitation of required copyability for the values inside and with the possibility to set a custom allocator. | 
| atomic.hpp | Utility extensions for <atomic>. | 
| atomic_shared_ptr_storage.hpp | A wrapper for std::shared_ptr<T>which allows atomic load, store and exchange. An alternative to C++20'sstd::atomic<std::shared_ptr<T>>. | 
| data_mutex.hpp | A template pair of an object and a mutex used to synchronize access to it. It makes it hard to cause bugs by forgetting to lock a mutex associated with an object. | 
| dynamic_bitset.hpp | A class similar to std::bitset, but the number of bits is not a part of the type. It's also somewhat similar tostd::vector<bool>, but (so far) it has more limited modification capabilities. | 
| expected.hpp | A union type of a value and an error. Similar to the std::expectedfrom C++23. | 
| flat_map.hpp | A class with the interface of std::mapbut implemented with an underlyingstd::vector-type container, thus providing better cache locality of the elements. Similar toboost::flat_mapwith the notable difference that the underlying container can be changed via a template argument. | 
| flat_set.hpp | A class with the interface of std::setbut implemented with an underlyingstd::vector-type container, thus providing better cache locality of the elements. Similar toboost::flat_setwith the notable difference that the underlying container can be changed via a template argument. | 
| generator.hpp | A helper for making simple generator coroutines with co_yield. | 
| mem_streambuf.hpp | Two helper classes: mem_ostreambufandmem_istreambufwhich allow you to work withstd::stream-s with buffers of contiguous memory. | 
| opt_ref_buffer.hpp | A buffer that can either point to (reference) or own a contiguous block of memory | 
| pmr_allocator.hpp | A C++17 wrapper of std::pmr::polymorphic_allocatorwhich provides functionalities introduced in C++20 for it. | 
| pod_vector.hpp | A container similar to std::vector, which contains PODs. This fact is used to improve performance by skipping constructor and destructor calls and usingmemcpyandmemmoveto copy data, andmallocandfree, and, most importantlyrealloc, and_expandif available, to manage memory. | 
| poly_span.hpp | A class similar to C++20's std::spanwhich offers a polymorphic view over a buffer of objects. | 
| qalgorithm.hpp | Wrappers of <algorithm>functions which work on entire containers for less typing in the most common use-cases. | 
| rand_dist.hpp | Alternative random distributions compatible with std::random. | 
| rstream.hpp | Read stream. Simple std::istreamwrappers which don't allow seeks, allowing you to be certain that reads are sequential, and thus allow a redirect, so you can represent several streams as one. | 
| sentry.hpp | A sentry class which executes a function object on destruction. Works with C++11, but it's slightly easier to use with C++17. | 
| shared_from.hpp | A helper class to replace std::enable_shared_from_thisproviding a more powerful interface. Similar toenable_shared_fromfrom Boost.SmartPtr | 
| small_vector.hpp | A mix between std::vectoranditlib::static_vector. It's a dynamic array, optimized for use when the number of elements is small. Likestatic_vectoris has a static buffer with a given capacity, but can fall back to dynamically allocated memory, should the size exceed it. Similar toboost::small_vector | 
| span.hpp | A C++11 implementation of C++20's std::span | 
| static_vector.hpp | A mix between std::vectorandstd::array: A dynamically sized container with fixed capacity (supplied as a template parameter). This allows you to have dynamically sized vectors on the stack or as cache-local value members, as long as you know a big enough capacity beforehand. Similar toboost::static_vector. | 
| stride_span.hpp | A C++11 implementation C++20's of std::span with a dynamic extent and an associated stride. | 
| strutil.hpp | A collection of small utilities for std::string_view | 
| throw_ex.hpp | Utility to compose and throw exceptions on a single line | 
| time_t.hpp | A thin wrapper of std::time_twhich provides thread safestd::tmgetters and type-safe (std::chrono::duration-based) arithmetic | 
| type_traits.hpp | Additional type traits to extend the standard library's <type_traits> | 
| ufunction.hpp | Unique function. A replacement of std::functionwhich is non-copyable (can capture non-copyable values, and wrap non-copyable objects), and noexcept move-constructible (won't implicitly make owners no-noexcept move-constructible) | 
| utility.hpp | Several generally unrelated utility functions and helpers | 
Clone the repo or choose one or more libraries that you like and copy them somewhere in your include paths.
Every library is self-contained so you can copy, move, and modify whichever you like and not wory about interdependencies.
Pull requests and issues are welcome.
Please make separate commits per library, tagging them with the library name in the title with brackets. Example:
- [small_vector] Added insert methods
- [flat_map] Crash when using with xxxx container
You can use CMake to generate a project and run the tests locally.
Copyright © 2016-2019 Chobolabs Inc.
Copyright © 2020-2025 Borislav Stanimirov
These libraries are distributed under the MIT Software License. See LICENSE.txt for further details or copy here.