Skip to content

gabswb/vecx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vecx

A header-only C++ compile-time vector library using template metaprogramming.

Requirements

  • C++17 or later
  • CMake 3.14+

Building Tests and Example

mkdir build && cd build
cmake .. && make
./vecx_example

Usage

Simply 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{};
}

About

A header-only C++ compile-time vector library using template metaprogramming

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published