C++ header-only

Open-source C++ projects categorized as header-only

Top 23 C++ header-only Projects

  • json

    JSON for Modern C++

    Latest mention: GitHub Stale Bots – A False Economy | reddit.com/r/programming | 2021-01-18

    I use a stale bot on nlohmann/json and find it pretty useful (though I do not lock issues, but merely tag them "stale" and close them a bit later. Those issues can still be commented, and in the time they are marked stale, any comment will reopen them).

  • Catch2

    A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++11, C++14, C++17 and later (or C++03 on the Catch1.x branch)

    Latest mention: Resources that help you to delve into C++ | dev.to | 2021-01-16

    Now it is time to put C++ into practical usage. C++ is used for diverse purposes, and using C++ in specific areas is probably more critical than the C++ language itself. It is perhaps also a good time to spend some time on the broader C++ ecosystems, like unit test libraries such as Catch2, build system generators such as CMake, and package managers such as Conan.

  • spdlog

    Fast C++ logging library.

    Latest mention: What tools similar to std::optional should you be using? | reddit.com/r/cpp | 2021-01-02

    Yeah. I just added spdlog to a project and it's infuriating how the API expects things to be held in a shared pointer. Let me design my own ownership semantics!

  • crow

    Crow is very fast and easy to use C++ micro web framework (inspired by Python Flask)

  • GuiLite

    ✔️The smallest header-only GUI library(4 KLOC) for all platforms

    Latest mention: Deeply understand your GitHub/GitLab project | reddit.com/r/github | 2021-01-17

    You can get source code here

  • glm

    OpenGL Mathematics (GLM)

    Latest mention: Nyx: 3rd party libraries | dev.to | 2021-01-13

    glm [link]

  • entt

    Gaming meets modern C++ - a fast and reliable entity component system (ECS) and much more

    Latest mention: My Simple c++ ECS implementation | reddit.com/r/roguelikedev | 2021-01-15

    The API reminds me a bit of EnTT (Disclaimer: I am considered a contributor, even through its just a few lines). It makes heavy use internally of type-erasure (which would among other things remove the need for a common base class component) and other tricks and ideas you might get some inspiration from for your implementation.

  • cpp-httplib

    A C++ header-only HTTP/HTTPS server and client library

    Latest mention: How would you implement a basic REST API framework in C++ *from scratch*? | reddit.com/r/cpp_questions | 2021-01-07
  • doctest

    The fastest feature-rich C++11/14/17/20 single-header testing framework

  • compile-time-regular-expressions

    A Compile time PCRE (almost) compatible regular expression matcher.

    Latest mention: Discussion on possibility of a compile-time printf | reddit.com/r/cpp | 2021-01-02

    Until it’s in the standard have a look at, use and contribute to the work on GitHub (regex link, fmt link).

  • magic_enum

    Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code

    Latest mention: Conversion of two vectors with Variant class | reddit.com/r/cpp_questions | 2021-01-11

    If you want to find out the number of enums at compile time, there is ways to do that without the last element trick. Take a look at https://github.com/Neargye/magic_enum for how to (or just use the library, its great)

  • indicators

    Activity Indicators for Modern C++

    Latest mention: A Simple library for progress bars in C++ | reddit.com/r/cpp | 2021-01-13

    p-ranav/indicators offers a very rich api but this is definitely simpler to use.

  • PEGTL

    Parsing Expression Grammar Template Library

  • FunctionalPlus

    Functional Programming Library for C++. Write concise and readable C++ code.

    Latest mention: Best practice unit tests + examples with cmake | reddit.com/r/cpp | 2021-01-17

    You can copy this project structure: https://github.com/Dobiasd/FunctionalPlus

  • uvw

    Header-only, event based, tiny and easy to use libuv wrapper in modern C++ - now available as also shared/static library!

  • hana

    Your standard library for metaprogramming

    Latest mention: C Implementation Challenge Replacing Stdmove And | reddit.com/r/programming | 2020-09-23

    Boost.Hana developers measured a very noticeable 15% decrease in compile time switching from a function call (admittedly -- with an additional layer of wrapper) to a raw static_cast. foonathan himself saw a little over a 5% decrease in his actual code. miki151 saw about a 3% improvement from replacing move with MOV only, ignoring forward. In a completely synthetic benchmark where I just generate a ton of move calls in a row, I get a little over 40% decrease in compile time.

  • better-enums

    C++ compile-time enum to string, iteration, in a single header file

  • plog

    Portable, simple and extensible C++ logging library

  • nameof

    Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum

  • argh

    Argh! A minimalist argument handler.

  • frugally-deep

    Header-only library for using Keras models in C++.

  • inja

    A Template Engine for Modern C++

  • clipp

    easy to use, powerful & expressive command line argument parsing for modern C++ / single header / usage & doc generation

NOTE: The open source projects on this list are ordered by number of github stars. The number of mentions indicates repo mentiontions in the last 12 Months or since we started tracking (Dec 2020).

Index

What are some of the best open-source header-only projects in C++? This list will help you:

Project Stars
1 json 22,803
2 Catch2 12,649
3 spdlog 10,679
4 crow 6,156
5 GuiLite 5,148
6 glm 4,751
7 entt 4,598
8 cpp-httplib 4,293
9 doctest 3,001
10 compile-time-regular-expressions 1,723
11 magic_enum 1,541
12 indicators 1,364
13 PEGTL 1,247
14 FunctionalPlus 1,221
15 uvw 1,188
16 hana 1,186
17 better-enums 1,071
18 plog 1,011
19 nameof 947
20 argh 722
21 frugally-deep 698
22 inja 669
23 clipp 666