A header-only C++ compile-time vector library using template metaprogramming.
- C++17 or later
- CMake 3.14+
mkdir build && cd build
cmake .. && make
./vecx_exampleSimply include the header file in your project:
#include "vecx.h"
using namespace vecx;
// Create compile-time vectors
using my_vec = vector<1, 2, 3>;
using reversed = my_vec::reverse; // vector<3, 2, 1>
using extended = my_vec::push_back<4>; // vector<1, 2, 3, 4>
using sorted = vector<3, 1, 2>::sort; // vector<1, 2, 3>
// Chain operations naturally
using result = vector<'v','e','e','x'>::erase<1>::insert<'c',2>; // vector<'v','e','c','x'>
// Direct access to properties
static_assert(my_vec::size == 3);
static_assert(my_vec::min == 1);
static_assert(my_vec::sum == 6);
static_assert(my_vec::get<1> == 2);
// Classic API
static_assert(size_v<my_vec> == 3);
using sorted_classic = sort_t<vector<3, 1, 2>>;
int main() {
using hello = vector<'h','e','l','l','o'>;
using world = vector<'w','o','r','l','d','!'>;
using helloworld = hello::push_back<' '>::concat<world>;
std::cout << helloworld{};
}