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::any without 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's std::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 to std::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::expected from C++23. |
flat_map.hpp | A class with the interface of std::map but implemented with an underlying std::vector -type container, thus providing better cache locality of the elements. Similar to boost::flat_map with the notable difference that the underlying container can be changed via a template argument. |
flat_set.hpp | A class with the interface of std::set but implemented with an underlying std::vector -type container, thus providing better cache locality of the elements. Similar to boost::flat_set with 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 . |
pmr_allocator.hpp | A C++17 wrapper of std::pmr::polymorphic_allocator which provides functionalities introduced in C++20 for it. |
mem_streambuf.hpp | Two helper classes: mem_ostreambuf and mem_istreambuf which allow you to work with std::stream -s with buffers of contiguous memory. |
mem_streambuf.hpp | Two helper classes: mem_ostreambuf and mem_istreambuf which allow you to work with std::stream -s with buffers of contiguous memory. |
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 using memcpy and memmove to copy data, and malloc and free , and, most importantly realloc , and _expand if available, to manage memory. |
poly_span.hpp | A class similar to C++20's std::span which 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. |
rstream.hpp | Read stream. Simple std::istream wrappers 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_this providing a more powerful interface. Similar to enable_shared_from from Boost.SmartPtr |
small_vector.hpp | A mix between std::vector and itlib::static_vector . It's a dynamic array, optimized for use when the number of elements is small. Like static_vector is has a static buffer with a given capacity, but can fall back to dynamically allocated memory, should the size exceed it. Similar to boost::small_vector |
span.hpp | A C++11 implementation of C++20's std::span |
static_vector.hpp | A mix between std::vector and std::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 to boost::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_t which provides thread safe std::tm getters 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::function which 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-2024 Borislav Stanimirov
These libraries are distributed under the MIT Software License. See LICENSE.txt for further details or copy here.