All Projects → deepgrace → Monster

deepgrace / Monster

Licence: bsl-1.0
The Art of Template MetaProgramming (TMP) in Modern C++♦️

Programming Languages

cpp
1120 projects
metaprogramming
66 projects

Projects that are alternatives of or similar to Monster

C Plus Plus
Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
Stars: ✭ 17,151 (+18956.67%)
Mutual labels:  algorithm, search, sort
Javascript
A repository for All algorithms implemented in Javascript (for educational purposes only)
Stars: ✭ 16,117 (+17807.78%)
Mutual labels:  algorithm, search, sort
Algorithms
Minimal examples of data structures and algorithms in Python
Stars: ✭ 20,123 (+22258.89%)
Mutual labels:  algorithm, search, sort
Algorithm
The repository algorithms implemented on the Go
Stars: ✭ 163 (+81.11%)
Mutual labels:  algorithm, search, sort
Shards Dashboard Vue
A free Vue admin dashboard template pack featuring a modern design system and lots of custom templates and components.
Stars: ✭ 363 (+303.33%)
Mutual labels:  modern, template
Jstarcraft Rns
专注于解决推荐领域与搜索领域的两个核心问题:排序预测(Ranking)和评分预测(Rating). 为相关领域的研发人员提供完整的通用设计与参考实现. 涵盖了70多种排序预测与评分预测算法,是最快最全的Java推荐与搜索引擎.
Stars: ✭ 324 (+260%)
Mutual labels:  algorithm, search
Algorithms Primer
A consolidated collection of resources for you to learn and understand algorithms and data structures easily.
Stars: ✭ 381 (+323.33%)
Mutual labels:  algorithm, sort
Datastructureandalgorithms
Write code that run faster, use less memory and prepare for your Job Interview
Stars: ✭ 509 (+465.56%)
Mutual labels:  algorithm, sort
Codejam
Set of handy reusable .NET components that can simplify your daily work and save your time when you copy and paste your favorite helper methods and classes from one project to another
Stars: ✭ 217 (+141.11%)
Mutual labels:  algorithm, range
Java Algorithms Implementation
Algorithms and Data Structures implemented in Java
Stars: ✭ 3,927 (+4263.33%)
Mutual labels:  algorithm, sort
Period
PHP's time range API
Stars: ✭ 616 (+584.44%)
Mutual labels:  sequence, range
Klib
A standalone and lightweight C library
Stars: ✭ 3,442 (+3724.44%)
Mutual labels:  algorithm, sort
Data Structure Php Clanguage
对于数据结构和算法类的东西,我工作有些年份了,大学也有所涉猎,积累了一些内容,不高产不母猪,打我自己脸
Stars: ✭ 299 (+232.22%)
Mutual labels:  algorithm, sort
Fill Range
Fill in a range of numbers or letters, positive or negative, optionally passing an increment or multiplier to use.
Stars: ✭ 41 (-54.44%)
Mutual labels:  sequence, range
Fastrange
A fast alternative to the modulo reduction
Stars: ✭ 230 (+155.56%)
Mutual labels:  algorithm, range
Algorithms
CLRS study. Codes are written with golang.
Stars: ✭ 482 (+435.56%)
Mutual labels:  algorithm, sort
Dsa.js Data Structures Algorithms Javascript
🥞Data Structures and Algorithms explained and implemented in JavaScript + eBook
Stars: ✭ 6,251 (+6845.56%)
Mutual labels:  algorithm, search
Latexcv
👔 A collection of cv and resume templates written in LaTeX. Leave an issue if your language is not supported!
Stars: ✭ 1,027 (+1041.11%)
Mutual labels:  modern, template
C
Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.
Stars: ✭ 11,897 (+13118.89%)
Mutual labels:  search, sort
Technicalnote
Repository to store what we have studied. 📖 We want everyone to get a job through TechnicalNote.
Stars: ✭ 206 (+128.89%)
Mutual labels:  algorithm, sort

Monster LICENSE Documentation Language Platform Gitter Chat

Advanced C++ Template MetaProgramming Framework

Overview

#include <monster.hpp>
using namespace monster;

int main(int argc, char* argv[])
{
    // arrange the same elements adjacent in a sequence, keep the relative order
    using a1 = adjacent_t<std::tuple<char, double, char, int, double>>;
    using a2 = adjacent_t<std::index_sequence<4, 3, 0, 3, 2, 4, 5, 3>>;
    static_assert(std::is_same_v<a1, std::tuple<char, char, double, double, int>>);
    static_assert(std::is_same_v<a2, std::index_sequence<4, 4, 3, 3, 3, 0, 2, 5>>);

    // Boyer-Moore-Horspool (BMH) algorithm searches for occurrences of a sequence within another sequence
    using b1 = bmh_t<std::tuple<int, char, int>, std::tuple<int, int, char, int, char, int, char, int>>;
    using b2 = bmh_t<std::integer_sequence<int, 7, 5>, std::integer_sequence<int, 7, 5, 4, 0, 7, 5, 9>>;
    static_assert(std::is_same_v<b1, std::index_sequence<1, 3, 5>>);
    static_assert(std::is_same_v<b2, std::index_sequence<0, 4>>);

    // Knuth–Morris–Pratt (KMP) algorithm searches for occurrences of a sequence within another sequence
    using k1 = kmp_t<std::tuple<int, char, int>, std::tuple<int, int, char, int, char, int, char, int>>;
    using k2 = kmp_t<std::integer_sequence<int, 7, 5>, std::integer_sequence<int, 7, 5, 4, 0, 7, 5, 9>>;
    static_assert(std::is_same_v<k1, std::index_sequence<1, 3, 5>>);
    static_assert(std::is_same_v<k2, std::index_sequence<0, 4>>);

    // find K-th smallest element in a sequence (k == 2)
    using min1 = select_t<2, std::tuple<short, int, double, int, char>>;
    using min2 = select_t<2, std::integer_sequence<int, -2, 1, 0, -7, 4, 3>>;
    static_assert(std::is_same_v<min1, short>);
    static_assert(std::is_same_v<min2, c_<-2>>);

    // find K-th greatest element in a sequence (k == 2)
    using max1 = select_t<2, std::tuple<short, int, double, int, char>, greater_equal_t>;
    constexpr auto max2 = select_v<2, std::integer_sequence<int, -2, 1, 0, -7, 4, 3>, greater_equal_t>;
    static_assert(std::is_same_v<max1, int>);
    static_assert(max2 == 3);

    // returns element at specific index of a sequence
    using e1 = element_t<1, std::tuple<char, double, int>>;
    using e2 = element_t<3, std::integer_sequence<int, 1, -2, 7, 4>>;
    constexpr auto e3 = element_v<3, std::integer_sequence<int, 1, -2, 7, 4>>;
    static_assert(std::is_same_v<e1, double>);
    static_assert(std::is_same_v<e2, c_4>);
    static_assert(e3 == 4);

    // remove duplicate elements from a sequence, keep the first appearance
    using u1 = unique_t<std::tuple<int, char, int, double>>;
    using u2 = unique_t<std::integer_sequence<int, 2, 2, 3, 4, 3>>;
    static_assert(std::is_same_v<u1, std::tuple<int, char, double>>);
    static_assert(std::is_same_v<u2, std::integer_sequence<int, 2, 3, 4>>);

    // swap elements at specific index of a sequence
    using s1 = swap_t<1, 3, std::tuple<int, double, char, float>>;
    using s2 = swap_t<0, 2, std::integer_sequence<int, 1, -2, 7, 4>>;
    static_assert(std::is_same_v<s1, std::tuple<int, float, char, double>>);
    static_assert(std::is_same_v<s2, std::integer_sequence<int, 7, -2, 1, 4>>);

    // sort elements by value in a sequence
    using s3 = quick_sort_t<std::tuple<double, short, double, int, char, char, double>>;
    using s4 = quick_sort_t<std::integer_sequence<int, 2, 1, 0, -3, 4, 1, -7, 5, -2>>;
    static_assert(std::is_same_v<s3, std::tuple<char, char, short, int, double, double, double>>);
    static_assert(std::is_same_v<s4, std::integer_sequence<int, -7, -3, -2, 0, 1, 1, 2, 4, 5>>);

    // sort elements by index in a sequence
    using s5 = sort_index_t<std::tuple<double, short, double, int, char, char, double>>;
    using s6 = sort_index_t<std::integer_sequence<int, 2, 1, 0, -3, 4, 1, -7, 5, -2>>;
    static_assert(std::is_same_v<s5, std::index_sequence<4, 5, 1, 3, 6, 2, 0>>);
    static_assert(std::is_same_v<s6, std::index_sequence<6, 3, 8, 2, 1, 5, 0, 4, 7>>);

    // reverses the order of the elements of a sequence
    using r1 = reverse_t<std::tuple<float, double, int, short>>;
    using r2 = reverse_t<std::integer_sequence<int, 1, 0, 2, -2, 7, 6>>;
    static_assert(std::is_same_v<r1, std::tuple<short, int, double, float>>);
    static_assert(std::is_same_v<r2, std::integer_sequence<int, 6, 7, -2, 2, 0, 1>>);

    // reverses the order of the elements of a sequence recursively
    using r3 = reverse_recursive_t<std::tuple<int, std::tuple<int, std::tuple<char, short>>, char>>;
    using r4 = reverse_recursive_t<std::tuple<char, std::integer_sequence<int, 7, 2, 0, 4, 8>, int>>;
    static_assert(std::is_same_v<r3, std::tuple<char, std::tuple<std::tuple<short, char>, int>, int>>);
    static_assert(std::is_same_v<r4, std::tuple<int, std::integer_sequence<int, 8, 4, 0, 2, 7>, char>>);

    // rotates the elements in the range [begin, middle, end) of a sequence
    using r5 = rotate_t<0, 2, 5, std::tuple<int, char, double, float, int64_t>>;
    using r6 = rotate_t<2, 4, 7, std::integer_sequence<int, 9, 8, 1, 2, 3, 4, 5, 7, 6>>;
    static_assert(std::is_same_v<r5, std::tuple<double, float, int64_t, int, char>>);
    static_assert(std::is_same_v<r6, std::integer_sequence<int, 9, 8, 3, 4, 5, 1, 2, 7, 6>>);

    // returns the elements in the range [begin, end) of a sequence
    using r7 = range_t<1, 5, std::tuple<int, char, float, double, int, short>>;
    using r8 = range_t<2, 6, std::integer_sequence<int, 1, 2, -2, 4, 3, 5, 8, -5>>;
    static_assert(std::is_same_v<r7, std::tuple<char, float, double, int>>);
    static_assert(std::is_same_v<r8, std::integer_sequence<int, -2, 4, 3, 5>>);

    return 0;
}

Introduction

Monster is a metaprogramming library, which is header-only, extensible and modern C++ oriented.
It exhibits a form of pure type programming of compile-time algorithms, sequences and Higher-Order Metafunctions.

Monster provides a conceptual foundation and an extensive set of powerful and coherent tools, that makes doing explict advanced Template MetaProgramming (TMP) in modern C++ easy and enjoyable.

Compiler requirements

The library relies on a C++20 compiler and standard library, but nothing else is required.

More specifically, Monster requires a compiler/standard library supporting the following C++20 features (non-exhaustively):

  • concepts
  • lambda templates
  • All the C++20 type traits from the <type_traits> header

Building

Monster is header-only. To use it just add the necessary #include line to your source files, like this:

#include <monster.hpp>

To build the example with cmake, cd to the root of the project and setup the build directory:

mkdir build
cd build
cmake ..

Make and install the executables:

make -j4
make install

The executables are now located at the bin directory of the root of the project.
The example can also be built with the script build.sh, just run it, the executables will be put at the /tmp directory.

Documentation

You can browse the documentation online at Guidelines.md.
The documentation covers everything you should need including installing the library, a table of contents, and an extensive reference section with examples.

Full example

Please see Tutorial.md.

License

Monster is licensed as Boost Software License 1.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].