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
-
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.
-
Magic Enum C++
Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code
Project mention: What C++ library do you wish existed but hasn’t been created yet? | /r/cpp | 2023-07-08I'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
-
InfluxDB
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 C++
Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum
-
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):
https://strong-starlight-4ea0ed.netlify.app/
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.
-
Unless you want to make your own config file parser as an exercise (which is a good idea) I'd recommend using toml++.
-
Project 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
-
-
Onboard AI
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
span lite - A C++20-like span for C++98, C++11 and later in a single-file header-only library
Project mention: I love building a startup in Rust. I wouldn't pick it again. | /r/programming | 2023-02-18Another solution: use std::span (or some alternative implementations if the codebase doesn't use C++20).
-
string-view-lite
string_view lite - A C++17-like string_view for C++98, C++11 and later in a single-file header-only library
Project mention: Is there a std::string::split or something similar? | /r/cpp_questions | 2023-03-13There 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 lite - Expected objects in C++11 and later in a single-file header-only library
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.
-
-
-
-
ring-span-lite
ring-span lite - A C++yy-like ring_span type for C++98, C++11 and later in a single-file header-only library
-
Savefile-Saver
A program to backup all of your game savefiles on your system, neatly, and into a single folder.
-
SaaSHub
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
- Is there a std::string::split or something similar?
- The 23 year-old C++ developers with three job offers over $500k
- Nanobench: Fast, Accurate, Single-Header Microbenchmarking Functionality For C++
- C++ Return: std::any, std::optional, or std::variant?
-
A note from our sponsor - Onboard AI
getonboard.dev | 29 Nov 2023
Index
What are some of the best open-source single-file projects in C++? This list will help you:
Project | Stars | |
---|---|---|
1 | doctest | 5,307 |
2 | Magic Enum C++ | 4,058 |
3 | Nameof C++ | 1,821 |
4 | robin-hood-hashing | 1,455 |
5 | tomlplusplus | 1,245 |
6 | nanobench | 1,228 |
7 | Argh! | 1,205 |
8 | span-lite | 475 |
9 | string-view-lite | 379 |
10 | expected-lite | 325 |
11 | semver | 265 |
12 | serializer | 179 |
13 | scope_guard | 154 |
14 | ring-span-lite | 145 |
15 | Savefile-Saver | 8 |