🟩 Primitive types, asserts, compiler macros, Function, Span, Result
SaneCppFoundation.h is a library that provides many fundamental type definitions and types widely used by other libraries.
As this is included and needed by almost every other library, it tries to keep bloat to the bare minimum.
Detailed documentation is in the Foundation topic.
| Class | Description |
|---|---|
| SC::Span | Non-owning contiguous view over caller-provided memory |
| SC::StringSpan | Non-owning string view with explicit encoding |
| SC::StringPath | Non-owning path string view |
| SC::Result | Small success/error result type for APIs without exceptions |
| SC::Function | Fixed-storage callable wrapper |
| SC::Deferred | Scope-exit helper for explicit cleanup |
| SC::OpaqueObject | Fixed-size opaque storage for static PIMPL |
| SC::UniqueHandle | Move-only RAII wrapper for handles |
Compiler Macros Preprocessor macros to detect compiler and platform features.
| Class | Description |
|---|---|
| SC::Assert | Foundation-owned assertion provider |
| SC::AlignedStorage | Fixed-size aligned storage for hiding implementation details |
🟩 Usable
The library is very simple it it has what is needed so far by the other libraries.
There is an hard rule in the library Principles not to include system and compiler headers in public headers.
Foundation provides all primitive types to be used in headers and classes like SC::UniqueHandle, SC::OpaqueObject, SC::AlignedStorage to encourage static PIMPL in order to hide platform specific implementation details everywhere.
Fixed-storage callable wrapper used when APIs need callbacks without dynamic allocations.
Scope-exit helper used to run explicit cleanup code when leaving a scope.
Fixed-size opaque storage used to hide private implementation details in public headers.
Move-only RAII wrapper used to close or release handles deterministically.
Some relevant blog posts are:
🟦 Complete Features:
| Type | Lines Of Code | Comments | Sum |
|---|---|---|---|
| Headers | 1103 | 684 | 1787 |
| Sources | 362 | 72 | 434 |
| Sum | 1465 | 756 | 2221 |