Skip to content

GuillaumeDua/CppShelf

Repository files navigation

C++ Shelf

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.

  • FetchContent

    include(FetchContent)
    
    # Forces csl a options ...
    # example: set(CSL_ENABLE_ALL_TESTS OFF CACHE INTERNAL "")
    
    FetchContent_Declare(
        csl
        GIT_REPOSITORY https://github.com/GuillaumeDua/CppShelf.git
    )
    FetchContent_MakeAvailable(csl)
  • ExternalProject_Add

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 });
}

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