Sane C++ Libraries is a set of C++ platform abstraction libraries for macOS, Windows and Linux.
Principles:
β
Fast compile times
β
Bloat free
β
Simple and readable code
β
Easy to integrate
βοΈ No C++ Standard Library / Exceptions / RTTI
βοΈ No third party build dependencies (prefer OS API)
Libraries are designed to be used as Single File Libraries with minimal dependencies between them and follow a strict No Allocations (*) policy.
| Library | Description | Single File |
|---|---|---|
| Async | π¨ Async I/O (files, sockets, timers, processes, fs events, tasks) | Download |
| Async Streams | π¨ Concurrently read, write and transform byte streams | Download |
| Await | π¨ C++20 coroutine layer over Async | Download |
| Containers | π¨ Generic containers (SC::Vector, SC::SmallVector, SC::Array) | Download |
| Containers Reflection | π¨ Containers specializations for Reflection and Serialization | Download |
| File | π© Synchronous Disk File I/O | Download |
| File System | π© File System operations (like copy / delete) for files / dirs | Download |
| File System Iterator | π© Enumerates files and directories inside a given path | Download |
| File System Watcher | π© Notifications {add,remove,rename,modify} for files / dirs | Download |
| Foundation | π© Primitive types, asserts, macros, Function, Span, Result | Download |
| Hashing | π© Compute MD5, SHA1 or SHA256 hashes for bytes streams |
Download |
| Http | π₯ HTTP parser, client and server | Download |
| Http Client | π₯ Streaming-first HTTP client with native OS backends | Download |
| Memory | π© Custom allocators, Virtual Memory, Buffer, Segment | Download |
| Plugin | π¨ Minimal dependency based plugin system with hot-reload | Download |
| Process | π© Create child processes and redirect their input / output | Download |
| Reflection | π© Describe C++ types at compile time for serialization | Download |
| SerialPort | π¨ Serial port configuration and handling | Download |
| Serialization Binary | π¨ Serialize to and from a binary format using Reflection | Download |
| Serialization Text | π¨ Serialize to / from text formats (JSON) using Reflection | Download |
| Socket | π¨ Synchronous socket networking and DNS lookup | Download |
| Strings | π© String formatting / conversion / manipulation (UTF8 / UTF16) | Download |
| Testing | π¨ Simple testing framework used by all of the other libraries | Download |
| Threading | π© Atomic, thread, mutex, semaphore, barrier, rw-lock, condition | Download |
| Time | π¨ Time handling (relative, absolute, high resolution) | Download |
Each library is color-coded to signal its status:
π₯ Draft (incomplete, WIP, works on basic test cases)
π¨ MVP (a minimum set of features has been implemented)
π© Usable (a reasonable set of useful features has been implemented)
- Obtain a specific library:
- Downloading it from the above table or from the Latest Release page
- Assembling it from current
mainbranch using the Single File Library browser app
#include SaneCppLIBRARY.hin your headers#define SANE_CPP_IMPLEMENTATION+#include "SaneCppLIBRARY.h"in one of your.cppfiles
See Building (user) for details on the (system) libraries to link.
- Clone the entire repo and add it as subfolder of your project
- Add SC.cpp to your build system of choice
- Include any public header (
Libraries/[Library]/*.h)
See Building (user) for details on the (system) libraries to link.
- SCTest Suite showcases most functionalities of all libraries. Check Building (contributor) for details.
- Documentation page of each library embeds some examples and / or code snippets.
- Examples showcases some basic examples like an
AsyncWebServerand a more advancedSCExamplean Async event loop integration with a GUI and usage of Plugin. - Tools is a collection of repository / code automation tools built using libraries themselves
- Includes a fully self-hosted SC::Build build system where builds are imperatively described using C++ code, can generate XCode / Visual Studio / Make projects, and can also build directly through a native backend on macOS, Linux, and Windows.
- All libraries are designed to work inside user-provided memory buffers and can be used without dynamic memory allocation.
- All libraries return error codes when running out of such memory buffers (except in containers assignment operators, where they will assert).
- Memory and Containers are the only ones that will allocate by default, even if they support working inside fixed memory buffers (Opt-out allocation).
- Await uses by default caller-owned fixed buffers, while virtual memory, malloc/free, and polymorphic allocators are explicit opt-in modes (Opt-in allocation).
- Third-party container classes, including
std::ones, are fully supported (see InteropSTL for an example). - Memory and Containers are provided for convenience if user prefers them to
std::or to any other equivalent containers library, and they're totally optional.
Documentation is automatically generated using Doxygen and updated at every commit to main branch.
- Sane Coding Discord
- X
@pagghiu_ - Github Discussion
Sane C++ Libraries are licensed under the MIT License, see LICENSE.txt for more information.
On this YouTube Channel there are some videos showing bits of the development process.
On Sane Coding Blog there is a series of posts about this project.
Relevant yearly posts:
- Blog Post - Sane C++ Libraries (Open Sourcing)
- Blog Post - 1st Year of Sane C++ Libraries
- Blog Post - 2nd year of Sane C++ Libraries
- DeepWiki/SaneCppLibraries (AI-guided walkthrough of the project)