CppShelf

Collection of powerfuls - C++ Single-Header Libraries Files

View on GitHub

C++ Shelf

Fork me on GitHub Check documentation on GitHub-pages

cmake-Ubuntu-clang cmake-Ubuntu-gcc
pages-build-deployment Deploy-doc-to-GitHub-Pages
GitHub license GitHub top language GitHub issues GitHub commit activity


Collection of - Single-Header, header-only, C++ libraries files.
Personal incubator for various library ideas and experiences, and perhaps a hint of serendipity.

The libraries here could, once mature enough, become self-contained in a separated repository.


Components - nested librairies

📦 ag

A tuple-like interface for aggregates type.

Project’s documentation, dashboard

🌊 wf

Generic eDSL builder - as a route pattern - to best translate workflow/use-cases in C++

See project’s documentation, dashboard

🧙‍♂️ mp

A collection of C++ TMP (C++ template-metaprogramming) utilities

Project’s dashboard

🔬 functional

Function & overload traits

See project’s live demo on godbolt.org, dashboard

🔎 typeinfo

Compile-time demangler, for types & values.
Inconsistent: for educational and debugging purpose only.

See project’s live demo on godbolt.org, dashboard

ensure

Interface-safety related components, including a configurable strong-type implementation.

See project’s dashboard


Supported C++ standard

Library C++17 C++20 C++23
📦 ag
🌊 wf planned
P1985 - Universal template parameters
P0847 - Deducing this
🧙‍♂️ mp -
🔬 functional
🔎 typeinfo
☔ ensure

💡 Note that implementation details might changes from a version to another,
and in some cases, the source file itself.

For instance, we currently have: <csl/ensure.hpp> which either includes <csl/cxx_17/ensure.hpp>, or <csl/cxx_20/ensure.hpp> when C++20 or greater is available.

About C++17 support

💡 Backward compatibility with C++17 requires additional effort and IS NOT a priority for now, beside specific requests.

About C++23 support

⚠️ Implementations details might change once specific C++23 features are supported by targeted compilers.
👉 See opened issue tagged with C++23.

Supported compilers

Compiler Min. version Recommended Reason
g++ >= 11.1.0 >= 13.2 C++20
clang++ >= 13.0.1 >= 16.0.6 C++20
Decent support of P0315r4 lambdas in unevaluated contexts
msvc-cl TBD TBD -

Getting started

Getting started - using CMake

👉 This is the recommended way to integrate csl (or a subset of its components) to a project.

CMake - options

General options:

Option Type Default Description
CSL_BUILD_ALL bool ON enable/disable all components build
CSL_ENABLE_ALL_TESTS bool OFF enable/disable all components tests
CSL_ENABLE_ALL_EXAMPLES bool OFF enable/disable all components examples

Components-specific options:

Option syntax Type Default Description
CSL_BUILD_\<component_name\> BOOL CSL_BUILD_ALL enable/disable a specific component build
CSL_TEST_\<component_name\> BOOL CSL_ENABLE_ALL_TESTS enable/disable a specific component test
CSL_EXAMPLE_\<component_name\> BOOL CSL_ENABLE_ALL_EXAMPLES enable/disable a specific component example

For options related to a specific component, refer to its dedicated documentation.

Getting started - header-only

Using the way you prefer, acquire a component/library file.

Use it in your project using an #include preprocessor directive.
Refer to the component’s documention to check for configuration preprocessor constant.

Example:

#define CSL_ENSURE__ENABLE_FMT_SUPPORT // enable `fmt` support, if available
#include <csl/ensure.hpp>

void func(){
    using meters = csl::ensure::strong_type<int, struct meter_tag>;
    fmt::print(meters{ 42 });
}

In Compiler Explorer

See demonstration here.

#include <iostream>

#include <https://raw.githubusercontent.com/GuillaumeDua/CppShelf/main/includes/typeinfo/csl/typeinfo.hpp>
#include <https://raw.githubusercontent.com/GuillaumeDua/CppShelf/main/includes/ag/csl/ag.hpp>

struct some_model {
    char c = 'A';
    int i = 42;
};

auto main() -> int {
    std::cout
        << csl::typeinfo::type_name_v<
            csl::ag::element_t<0, some_model> // "char"
           >
    ;
    return csl::ag::get<1>(some_model{}); // 42
}

Possible output:

Program returned: 42
Program stdout
char

Misc

This Readme.md ‘s ressources