Home

Awesome

itlib: iboB's Template Libraries

A collection of small single-header C++ libraries similar to or extending the C++ standard library. See below for a list.

Language License

itlib was forked from chobo-shl which is no longer supported. New libraries and updates to the existing ones are added here.

Build Status

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.

Build

Libraries

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.

LibraryDescription
any.hpp StandardAn 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 StandardUtility extensions for <atomic>.
atomic_shared_ptr_storage.hpp StandardA 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 Standard StandardA 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 StandardA 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 StandardA union type of a value and an error. Similar to the std::expected from C++23.
flat_map.hpp StandardA 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 StandardA 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 StandardA helper for making simple generator coroutines with co_yield.
pmr_allocator.hpp StandardA C++17 wrapper of std::pmr::polymorphic_allocator which provides functionalities introduced in C++20 for it.
mem_streambuf.hpp StandardTwo helper classes: mem_ostreambuf and mem_istreambuf which allow you to work with std::stream-s with buffers of contiguous memory.
mem_streambuf.hpp StandardTwo helper classes: mem_ostreambuf and mem_istreambuf which allow you to work with std::stream-s with buffers of contiguous memory.
pod_vector.hpp StandardA 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 StandardA class similar to C++20's std::span which offers a polymorphic view over a buffer of objects.
qalgorithm.hpp StandardWrappers of <algorithm> functions which work on entire containers for less typing in the most common use-cases.
rstream.hpp StandardRead 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 Standard StandardA 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 StandardA 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 StandardA 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 Standard StandardA C++11 implementation of C++20's std::span
static_vector.hpp StandardA 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 StandardA C++11 implementation C++20's of std::span with a dynamic extent and an associated stride.
strutil.hpp StandardA collection of small utilities for std::string_view
throw_ex.hpp StandardUtility to compose and throw exceptions on a single line
time_t.hpp StandardA thin wrapper of std::time_t which provides thread safe std::tm getters and type-safe (std::chrono::duration-based) arithmetic
type_traits.hpp Standard StandardAdditional type traits to extend the standard library's <type_traits>
ufunction.hpp Standard StandardUnique 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 StandardSeveral generally unrelated utility functions and helpers

Usage

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.

Contributing

Pull requests and issues are welcome.

Please make separate commits per library, tagging them with the library name in the title with brackets. Example:

You can use CMake to generate a project and run the tests locally.

Copyright

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.