{"id":13730535,"url":"https://github.com/deepgrace/monster","last_synced_at":"2025-05-08T03:30:52.242Z","repository":{"id":187699854,"uuid":"100332973","full_name":"deepgrace/monster","owner":"deepgrace","description":"The Art of Template MetaProgramming (TMP) in Modern C++♦️","archived":false,"fork":false,"pushed_at":"2024-06-06T12:37:54.000Z","size":1026,"stargazers_count":154,"open_issues_count":0,"forks_count":15,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-08-04T02:09:37.563Z","etag":null,"topics":["advanced","algorithm","c-plus-plus","concept","concepts","cpp20","header-only","metaprogram","metaprogramming","modern","monster","range","search","sequence","sort","template","template-metaprogramming","tmp","tuple","type-traits"],"latest_commit_sha":null,"homepage":"https://deepgrace.github.io/monster","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepgrace.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE_1_0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-08-15T03:06:51.000Z","updated_at":"2024-08-01T02:46:41.000Z","dependencies_parsed_at":"2024-04-27T10:31:01.134Z","dependency_job_id":"d41f741e-e451-43c4-8a3b-6cd04c8c3c9e","html_url":"https://github.com/deepgrace/monster","commit_stats":null,"previous_names":["deepgrace/monster"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgrace%2Fmonster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgrace%2Fmonster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgrace%2Fmonster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgrace%2Fmonster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepgrace","download_url":"https://codeload.github.com/deepgrace/monster/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224695554,"owners_count":17354431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advanced","algorithm","c-plus-plus","concept","concepts","cpp20","header-only","metaprogram","metaprogramming","modern","monster","range","search","sequence","sort","template","template-metaprogramming","tmp","tuple","type-traits"],"created_at":"2024-08-03T02:01:16.214Z","updated_at":"2024-11-14T21:31:11.573Z","avatar_url":"https://github.com/deepgrace.png","language":"C++","readme":"# Monster [![LICENSE](https://img.shields.io/github/license/deepgrace/monster.svg)](https://github.com/deepgrace/monster/blob/master/LICENSE_1_0.txt) [![Documentation](https://img.shields.io/badge/documentation-master-brightgreen.svg)](https://github.com/deepgrace/monster/blob/master/Guidelines.md) [![Language](https://img.shields.io/badge/language-C%2B%2B20-blue.svg)](https://en.cppreference.com/w/cpp/compiler_support) [![Platform](https://img.shields.io/badge/platform-Linux%20%7C%20MacOS%20%7C%20Windows-lightgrey.svg)](https://github.com/deepgrace/monster) [![Gitter Chat](https://img.shields.io/badge/gitter-join%20chat-red.svg)](https://gitter.im/taotmp/monster)\n\n\u003e **Advanced C++ Template MetaProgramming Framework**\n\n## Overview\n```cpp\n#include \u003ccstdint\u003e\n#include \u003cmonster.hpp\u003e\n\nusing namespace monster;\n\nint main(int argc, char* argv[])\n{\n    // arrange the same elements adjacent in a sequence, keep the relative order\n    using a1 = adjacent_t\u003cstd::tuple\u003cchar, double, char, int, double\u003e\u003e;\n    using a2 = adjacent_t\u003cstd::index_sequence\u003c4, 3, 0, 3, 2, 4, 5, 3\u003e\u003e;\n\n    static_assert(std::is_same_v\u003ca1, std::tuple\u003cchar, char, double, double, int\u003e\u003e);\n    static_assert(std::is_same_v\u003ca2, std::index_sequence\u003c4, 4, 3, 3, 3, 0, 2, 5\u003e\u003e);\n\n    // Boyer-Moore-Horspool (BMH) algorithm searches for occurrences of a sequence within another sequence\n    using b1 = bmh_t\u003cstd::tuple\u003cint, char, int\u003e, std::tuple\u003cint, int, char, int, char, int, char, int\u003e\u003e;\n    using b2 = bmh_t\u003cstd::integer_sequence\u003cint, 7, 5\u003e, std::integer_sequence\u003cint, 7, 5, 4, 0, 7, 5, 9\u003e\u003e;\n\n    static_assert(std::is_same_v\u003cb1, std::index_sequence\u003c1, 3, 5\u003e\u003e);\n    static_assert(std::is_same_v\u003cb2, std::index_sequence\u003c0, 4\u003e\u003e);\n\n    // Knuth–Morris–Pratt (KMP) algorithm searches for occurrences of a sequence within another sequence\n    using k1 = kmp_t\u003cstd::tuple\u003cint, char, int\u003e, std::tuple\u003cint, int, char, int, char, int, char, int\u003e\u003e;\n    using k2 = kmp_t\u003cstd::integer_sequence\u003cint, 7, 5\u003e, std::integer_sequence\u003cint, 7, 5, 4, 0, 7, 5, 9\u003e\u003e;\n\n    static_assert(std::is_same_v\u003ck1, std::index_sequence\u003c1, 3, 5\u003e\u003e);\n    static_assert(std::is_same_v\u003ck2, std::index_sequence\u003c0, 4\u003e\u003e);\n\n    // find K-th smallest element in a sequence (k == 2)\n    using min1 = select_t\u003c2, std::tuple\u003cshort, int, double, int, char\u003e\u003e;\n    using min2 = select_t\u003c2, std::integer_sequence\u003cint, -2, 1, 0, -7, 4, 3\u003e\u003e;\n\n    static_assert(std::is_same_v\u003cmin1, short\u003e);\n    static_assert(std::is_same_v\u003cmin2, c_\u003c-2\u003e\u003e);\n\n    // find K-th greatest element in a sequence (k == 2)\n    using max1 = select_t\u003c2, std::tuple\u003cshort, int, double, int, char\u003e, greater_equal_t\u003e;\n    constexpr auto max2 = select_v\u003c2, std::integer_sequence\u003cint, -2, 1, 0, -7, 4, 3\u003e, greater_equal_t\u003e;\n\n    static_assert(std::is_same_v\u003cmax1, int\u003e);\n    static_assert(max2 == 3);\n\n    // returns element at specific index of a sequence\n    using e1 = element_t\u003c1, std::tuple\u003cchar, double, int\u003e\u003e;\n    using e2 = element_t\u003c3, std::integer_sequence\u003cint, 1, -2, 7, 4\u003e\u003e;\n\n    constexpr auto e3 = element_v\u003c3, std::integer_sequence\u003cint, 1, -2, 7, 4\u003e\u003e;\n\n    static_assert(std::is_same_v\u003ce1, double\u003e);\n    static_assert(std::is_same_v\u003ce2, c_4\u003e);\n\n    static_assert(e3 == 4);\n\n    // remove duplicate elements from a sequence, keep the first appearance\n    using u1 = unique_t\u003cstd::tuple\u003cint, char, int, double\u003e\u003e;\n    using u2 = unique_t\u003cstd::integer_sequence\u003cint, 2, 2, 3, 4, 3\u003e\u003e;\n\n    static_assert(std::is_same_v\u003cu1, std::tuple\u003cint, char, double\u003e\u003e);\n    static_assert(std::is_same_v\u003cu2, std::integer_sequence\u003cint, 2, 3, 4\u003e\u003e);\n\n    // swap elements at specific index of a sequence\n    using s1 = swap_t\u003c1, 3, std::tuple\u003cint, double, char, float\u003e\u003e;\n    using s2 = swap_t\u003c0, 2, std::integer_sequence\u003cint, 1, -2, 7, 4\u003e\u003e;\n\n    static_assert(std::is_same_v\u003cs1, std::tuple\u003cint, float, char, double\u003e\u003e);\n    static_assert(std::is_same_v\u003cs2, std::integer_sequence\u003cint, 7, -2, 1, 4\u003e\u003e);\n\n    // sort elements by value in a sequence\n    using s3 = quick_sort_t\u003cstd::tuple\u003cdouble, short, double, int, char, char, double\u003e\u003e;\n    using s4 = quick_sort_t\u003cstd::integer_sequence\u003cint, 2, 1, 0, -3, 4, 1, -7, 5, -2\u003e\u003e;\n\n    static_assert(std::is_same_v\u003cs3, std::tuple\u003cchar, char, short, int, double, double, double\u003e\u003e);\n    static_assert(std::is_same_v\u003cs4, std::integer_sequence\u003cint, -7, -3, -2, 0, 1, 1, 2, 4, 5\u003e\u003e);\n\n    // sort elements by index in a sequence\n    using s5 = sort_index_t\u003cstd::tuple\u003cdouble, short, double, int, char, char, double\u003e\u003e;\n    using s6 = sort_index_t\u003cstd::integer_sequence\u003cint, 2, 1, 0, -3, 4, 1, -7, 5, -2\u003e\u003e;\n\n    static_assert(std::is_same_v\u003cs5, std::index_sequence\u003c4, 5, 1, 3, 6, 2, 0\u003e\u003e);\n    static_assert(std::is_same_v\u003cs6, std::index_sequence\u003c6, 3, 8, 2, 1, 5, 0, 4, 7\u003e\u003e);\n\n    // reverses the order of the elements of a sequence\n    using r1 = reverse_t\u003cstd::tuple\u003cfloat, double, int, short\u003e\u003e;\n    using r2 = reverse_t\u003cstd::integer_sequence\u003cint, 1, 0, 2, -2, 7, 6\u003e\u003e;\n\n    static_assert(std::is_same_v\u003cr1, std::tuple\u003cshort, int, double, float\u003e\u003e);\n    static_assert(std::is_same_v\u003cr2, std::integer_sequence\u003cint, 6, 7, -2, 2, 0, 1\u003e\u003e);\n\n    // reverses the order of the elements of a sequence recursively\n    using r3 = reverse_recursive_t\u003cstd::tuple\u003cint, std::tuple\u003cint, std::tuple\u003cchar, short\u003e\u003e, char\u003e\u003e;\n    using r4 = reverse_recursive_t\u003cstd::tuple\u003cchar, std::integer_sequence\u003cint, 7, 2, 0, 4, 8\u003e, int\u003e\u003e;\n\n    static_assert(std::is_same_v\u003cr3, std::tuple\u003cchar, std::tuple\u003cstd::tuple\u003cshort, char\u003e, int\u003e, int\u003e\u003e);\n    static_assert(std::is_same_v\u003cr4, std::tuple\u003cint, std::integer_sequence\u003cint, 8, 4, 0, 2, 7\u003e, char\u003e\u003e);\n\n    // rotates the elements in the range [begin, middle, end) of a sequence\n    using r5 = rotate_t\u003c0, 2, 5, std::tuple\u003cint, char, double, float, int64_t\u003e\u003e;\n    using r6 = rotate_t\u003c2, 4, 7, std::integer_sequence\u003cint, 9, 8, 1, 2, 3, 4, 5, 7, 6\u003e\u003e;\n\n    static_assert(std::is_same_v\u003cr5, std::tuple\u003cdouble, float, int64_t, int, char\u003e\u003e);\n    static_assert(std::is_same_v\u003cr6, std::integer_sequence\u003cint, 9, 8, 3, 4, 5, 1, 2, 7, 6\u003e\u003e);\n\n    // returns the elements in the range [begin, end) of a sequence\n    using r7 = range_t\u003c1, 5, std::tuple\u003cint, char, float, double, int, short\u003e\u003e;\n    using r8 = range_t\u003c2, 6, std::integer_sequence\u003cint, 1, 2, -2, 4, 3, 5, 8, -5\u003e\u003e;\n\n    static_assert(std::is_same_v\u003cr7, std::tuple\u003cchar, float, double, int\u003e\u003e);\n    static_assert(std::is_same_v\u003cr8, std::integer_sequence\u003cint, -2, 4, 3, 5\u003e\u003e);\n\n    return 0;\n}\n```\n\n## Introduction\nMonster is a metaprogramming library, which is header-only, extensible and modern C++ oriented.  \nIt exhibits a form of pure type programming of compile-time algorithms, sequences and Higher-Order Metafunctions.\n\nMonster provides a conceptual foundation and an extensive set of powerful and coherent tools, that\nmakes doing explict advanced Template MetaProgramming (**TMP**) in modern C++ easy and enjoyable.\n\n## Compiler requirements\nThe library relies on a C++20 compiler and standard library, but nothing else is required.\n\nMore specifically, Monster requires a compiler/standard library supporting the following C++20 features (non-exhaustively):\n- concepts\n- lambda templates\n- All the C++20 type traits from the \u003ctype_traits\u003e header\n\n## Building\nMonster is header-only. To use it just add the necessary `#include` line to your source files, like this:\n```cpp\n#include \u003cmonster.hpp\u003e\n```\n\nTo build the example with cmake, `cd` to the root of the project and setup the build directory:\n```bash\nmkdir build\ncd build\ncmake ..\n```\n\nMake and install the executables:\n```\nmake -j4\nmake install\n```\nThe executables are now located at the `bin` directory of the root of the project.  \nThe example can also be built with the script `build.sh`, just run it, the executables will be put at the `/tmp` directory.\n\n## Documentation\nYou can browse the documentation online at [Guidelines.md](Guidelines.md).  \nThe documentation covers everything you should need including installing the library,\na table of contents, and an extensive reference section with examples.\n\n## Full example\nPlease see [Tutorial.md](Tutorial.md).\n\n## License\nMonster is licensed as [Boost Software License 1.0](LICENSE_1_0.txt).\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepgrace%2Fmonster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepgrace%2Fmonster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepgrace%2Fmonster/lists"}