https://github.com/guillaumedua/cppshelf
Collection of powerfuls - C++ Single-Header Libraries Files
https://github.com/guillaumedua/cppshelf
cpp cpp20 metaprogramming
Last synced: 2 months ago
JSON representation
Collection of powerfuls - C++ Single-Header Libraries Files
- Host: GitHub
- URL: https://github.com/guillaumedua/cppshelf
- Owner: GuillaumeDua
- License: mit
- Created: 2021-06-14T19:19:29.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T20:36:48.000Z (11 months ago)
- Last Synced: 2024-10-29T22:50:02.153Z (11 months ago)
- Topics: cpp, cpp20, metaprogramming
- Language: C++
- Homepage: https://guillaumedua.github.io/CppShelf/
- Size: 9.86 MB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 160
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# C++ Shelf
[](https://github.com/GuillaumeDua/CppShelf/actions/workflows/cmake-Ubuntu-clang.yml)
[](https://github.com/GuillaumeDua/CppShelf/actions/workflows/cmake-Ubuntu-gcc.yml)
[](https://github.com/GuillaumeDua/CppShelf/actions/workflows/pages/pages-build-deployment)
[](https://github.com/GuillaumeDua/CppShelf/actions/workflows/docs_to_gh_pages.yml)
[](https://github.com/GuillaumeDua/CppShelf/blob/main/LICENSE)

[](https://github.com/GuillaumeDua/CppShelf/issues)
---
Collection of - ***S**ingle-**He**ader, header-only, C++ **l**ibraries **f**iles*.
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](https://github.com/GuillaumeDua/CppShelf/blob/main/includes/ag/csl/ag.hpp)
A **tuple-like** interface for **aggregates** type.
Project's
[documentation](https://guillaumedua.github.io/CppShelf/output/ag/),
[dashboard](https://github.com/users/GuillaumeDua/projects/2)### 🌊 [wf](https://github.com/GuillaumeDua/CppShelf/blob/main/docs/details/markdown/wf.md)
Generic **eDSL** builder - *as a route pattern* - to best translate **workflow**/use-cases in C++
See project's
[documentation](https://guillaumedua.github.io/CppShelf/output/wf/),
[dashboard](https://github.com/GuillaumeDua/CppShelf/projects/1)### 🧙♂️ [mp](https://github.com/GuillaumeDua/CppShelf/blob/main/includes/mp/csl/mp.hpp)
A collection of **C++ TMP** *(C++ template-metaprogramming)* utilities
Project's [dashboard](https://github.com/users/GuillaumeDua/projects/3)
### 🔬 [functional](https://github.com/GuillaumeDua/CppShelf/blob/main/includes/functional/csl/functional.hpp)
Function & overload traits
See project's
[live demo on godbolt.org](https://godbolt.org/z/Gd7fMKK8e),
[dashboard](https://github.com/users/GuillaumeDua/projects/5)### 🔎 [typeinfo](https://github.com/GuillaumeDua/CppShelf/blob/main/includes/typeinfo/csl/typeinfo.hpp)
Compile-time demangler, for types & values.
Inconsistent: for educational and debugging purpose only.See project's
[live demo on godbolt.org](https://godbolt.org/z/TsEWf5bGa),
[dashboard](https://github.com/users/GuillaumeDua/projects/7)### ☔ [ensure](https://github.com/GuillaumeDua/CppShelf/blob/main/includes/ensure/csl/ensure.hpp)
Interface-safety related components, including a configurable **strong-type** implementation.
See project's
[dashboard](https://github.com/users/GuillaumeDua/projects/4)---
## Supported C++ standard
| Library | C++17 | C++20 | C++23 |
| ------------- | :---: | :---: | :---- |
| 📦 ag | ❌ | ✅ | ✅ |
| 🌊 wf | ❌ | ✅ | *planned*
[P1985 - Universal template parameters](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1985r1.pdf)
[P0847 - Deducing this](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0847r5.html) |
| 🧙♂️ 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:
> `` which either includes ``, or `` 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](https://en.cppreference.com/w/cpp/compiler_support) by targeted compilers.
👉 See opened issue [tagged with C++23](https://github.com/GuillaumeDua/CppShelf/issues?q=is%3Aissue+is%3Aopen+label%3AC%2B%2B23).## 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](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0315r4.pdf) |
| **`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](https://cmake.org/cmake/help/latest/module/FetchContent.html)
```cmake
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](https://cmake.org/cmake/help/latest/module/ExternalProject.html)
#### 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_\` | BOOL | `CSL_BUILD_ALL` | enable/disable a specific component **build** |
| `CSL_TEST_\` | BOOL | `CSL_ENABLE_ALL_TESTS` | enable/disable a specific component **test** |
| `CSL_EXAMPLE_\` | 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.
- `wget` shell command
- CMake [`file(DOWNLOAD [] [...])`](https://cmake.org/cmake/help/latest/command/file.html)
- etc.Use it in your project using an `#include` preprocessor directive.
Refer to the component's documention to check for configuration preprocessor constant.Example:
```cpp
#define CSL_ENSURE__ENABLE_FMT_SUPPORT // enable `fmt` support, if available
#includevoid func(){
using meters = csl::ensure::strong_type;
fmt::print(meters{ 42 });
}
```### In [Compiler Explorer](https://godbolt.org/)
See [demonstration here](https://godbolt.org/z/4aGfEbf8d).
```cpp
#include#include
#includestruct 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
- [Shelf icons created by juicy_fish - Flaticon](https://www.flaticon.com/free-icons/shelf)