https://github.com/branc116/constexpr-list
Header only constexpr interger list library
https://github.com/branc116/constexpr-list
Last synced: 3 months ago
JSON representation
Header only constexpr interger list library
- Host: GitHub
- URL: https://github.com/branc116/constexpr-list
- Owner: branc116
- Created: 2021-03-14T19:36:23.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-25T10:30:14.000Z (over 1 year ago)
- Last Synced: 2025-07-08T10:45:48.202Z (3 months ago)
- Language: C++
- Size: 12.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Constexpr list with some algorithms
Header only constexpr cpp library for interger list manipulations.## Features
* Create lists in compile time
* Add elements dynamically in compile time to your lists
* Preform basic operations over your list
* get number of elements
* merge 2 or more lists into one
* reverse list
* take sub list of lists
* sort elements of the list
* everything in compile time## Example
example.cpp:
```cpp
#include "constexpr_list.hpp"
using namespace cxl;constexpr auto empty = empty_list(); // []
constexpr auto _1 = push_back<1>(empty); // [1]
constexpr auto _2 = push_back<2>(_1); // [1, 2]
constexpr auto _3 = push_back<3>(_2); // [1, 2, 3]
constexpr auto pb1 = push_back<2, 3, 4>(empty); // [2, 3, 4]
constexpr auto pf1 = push_front<2, 3, 4>(empty); // [4, 3, 2]
constexpr auto pb2 = push_back<10>(pf1); // [4, 3, 2, 10]constexpr auto f = first(pb2); // 4
constexpr auto l = last(pb2); // 10
constexpr auto g1 = pb2.get<0>(); // 4
constexpr auto g2 = pb2.get<3>(); // 10
constexpr auto g3 = pb2.get<4444>(); // NoneTypeconstexpr auto t1 = take*offset*/1, /*count*/2>(_3); // [2, 3]
constexpr auto t2 = take*count*/2>(_3); // [1, 2]constexpr auto m1 = merge(_3, _3); // [1, 1, 2, 2, 3, 3]
constexpr auto m2 = merge(_3, _3, _2, _1 /*, .... */); // [1, 1, 1, 1, 2, 2, 2, 3, 3]
constexpr auto m3 = merge(empty, empty); // []constexpr auto c1 = count(m2); // 3 + 3 + 2 + 1 = 9
constexpr auto c2 = count(empty); // 0constexpr auto r1 = reverse(m2); // [3, 3, 2, 2, 2, 1, 1, 1, 1]
constexpr auto r2 = reverse(empty); // []constexpr auto s1 = sort(_1); // [1]
constexpr auto s2 = sort(_2); // [1, 2]
constexpr auto s3 = sort(_3); // [1, 2, 3]
constexpr auto s4 = sort(pb2); // [2, 3, 4, 10]
constexpr auto s5 = sort(r1); // [1, 1, 1, 1, 2, 2, 2, 3, 3]
```
## Use cases
IDK.## How to build
You don't build this, you include this headers into you cpp file and you build your cpp file.
## Y?
Y not?