Onboard AI learns any GitHub repo in minutes and lets you chat with it to locate functionality, understand different parts, and generate new code. Use it for free at www.getonboard.dev. Learn more →
Top 15 C++ single-file Projects
The fastest feature-rich C++11/14/17/20/23 single-header testing frameworkProject mention: Unit testing tool suggestions | /r/learnprogramming | 2023-05-07
I have never used "tools" for unit-tests, only web sites that show the results of the tests or code coverage. For C++ I prefer https://github.com/doctest/doctest but most companies I worked for use Catch2.
Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate codeProject mention: What C++ library do you wish existed but hasn’t been created yet? | /r/cpp | 2023-07-08
I'm not sure this is quite what you're asking for, but this library has been super helpful to me in the past : https://github.com/Neargye/magic_enum
Collect and Analyze Billions of Data Points in Real Time. Manage all types of time series data in a single, purpose-built database. Run at any scale in any environment in the cloud, on-premises, or at the edge.
Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum
Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20Project mention: Factor is faster than Zig | news.ycombinator.com | 2023-11-10
In my example the table stores the hash codes themselves instead of the keys (because the hash function is invertible)
Oh, I see, right. If determining the home bucket is trivial, then the back-shifting method is great. The issue is just that it’s not as much of a general-purpose solution as it may initially seem.
“With a different algorithm (Robin Hood or bidirectional linear probing), the load factor can be kept well over 90% with good performance, as the benchmarks in the same repo demonstrate.”
I’ve seen the 90% claim made several times in literature on Robin Hood hash tables. In my experience, the claim is a bit exaggerated, although I suppose it depends on what our idea of “good performance” is. See these benchmarks, which again go up to a maximum load factor of 0.95 (Although boost and Absl forcibly grow/rehash at 0.85-0.9):
Tsl, Martinus, and CC are all Robin Hood tables (https://github.com/Tessil/robin-map, https://github.com/martinus/robin-hood-hashing, and https://github.com/JacksonAllan/CC, respectively). Absl and Boost are the well-known SIMD-based hash tables. Khash (https://github.com/attractivechaos/klib/blob/master/khash.h) is, I think, an ordinary open-addressing table using quadratic probing. Fastmap is a new, yet-to-be-published design that is fundamentally similar to bytell (https://www.youtube.com/watch?v=M2fKMP47slQ) but also incorporates some aspects of the aforementioned SIMD maps (it caches a 4-bit fragment of the hash code to avoid most key comparisons).
As you can see, all the Robin Hood maps spike upwards dramatically as the load factor gets high, becoming as much as 5-6 times slower at 0.95 vs 0.5 in one of the benchmarks (uint64_t key, 256-bit struct value: Total time to erase 1000 existing elements with N elements in map). Only the SIMD maps (with Boost being the better performer) and Fastmap appear mostly immune to load factor in all benchmarks, although the SIMD maps do - I believe - use tombstones for deletion.
I’ve only read briefly about bi-directional linear probing – never experimented with it.
Header-only TOML config file parser and serializer for C++17.Project mention: how to handle config files in c++? | /r/cpp_questions | 2023-03-06
Unless you want to make your own config file parser as an exercise (which is a good idea) I'd recommend using toml++.
Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20Project mention: The issue of unit tests and performance measurements (Benchmark) | /r/cpp | 2023-05-27
An alternative is tracking the number of instructions a test executes: https://github.com/martinus/nanobench
Argh! A minimalist argument handler. (by adishavit)
Learn any GitHub repo in 59 seconds. Onboard AI learns any GitHub repo in minutes and lets you chat with it to locate functionality, understand different parts, and generate new code. Use it for free at www.getonboard.dev.
span lite - A C++20-like span for C++98, C++11 and later in a single-file header-only libraryProject mention: I love building a startup in Rust. I wouldn't pick it again. | /r/programming | 2023-02-18
Another solution: use std::span (or some alternative implementations if the codebase doesn't use C++20).
string_view lite - A C++17-like string_view for C++98, C++11 and later in a single-file header-only libraryProject mention: Is there a std::string::split or something similar? | /r/cpp_questions | 2023-03-13
There are plenty of polyfill libraries that exist for std features like this. I strongly recommend using an existing one that attempts to match the standard closely. For example this one.
expected lite - Expected objects in C++11 and later in a single-file header-only libraryProject mention: Refactoring with C++17 std::optional | /r/cpp | 2023-05-22
Or nonstd::expected. Personally, I would rather use output parameters and an enum result or a std::variant over std::optional, because at the very least you have the option for more specific error diagnostics.
Semantic Versioning for modern C++ (by Neargye)
A single header standard C++ serialization framework. (by eyalz800)
A modern C++ scope guard that is easy to use but hard to misuse.
ring-span lite - A C++yy-like ring_span type for C++98, C++11 and later in a single-file header-only library
A program to backup all of your game savefiles on your system, neatly, and into a single folder.
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
C++ single-file related posts
Refactoring with C++17 std::optional
2 projects | /r/cpp | 22 May 2023
Is there a std::string::split or something similar?
2 projects | /r/cpp_questions | 13 Mar 2023
The 23 year-old C++ developers with three job offers over $500k
2 projects | /r/cpp | 22 Apr 2022
Nanobench: Fast, Accurate, Single-Header Microbenchmarking Functionality For C++
2 projects | /r/cpp | 9 Nov 2021
C++ Return: std::any, std::optional, or std::variant?
1 project | /r/cpp | 20 Sep 2021
A note from our sponsor - Onboard AI
getonboard.dev | 29 Nov 2023
What are some of the best open-source single-file projects in C++? This list will help you:
|2||Magic Enum C++||4,058|