{"id":17049802,"url":"https://github.com/marzer/type_list","last_synced_at":"2025-04-12T15:31:24.444Z","repository":{"id":63765060,"uuid":"372646970","full_name":"marzer/type_list","owner":"marzer","description":"A compiler-friendly variadic type list for C++.","archived":false,"fork":false,"pushed_at":"2023-06-14T16:45:19.000Z","size":89,"stargazers_count":36,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-26T10:11:20.123Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marzer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"marzer"}},"created_at":"2021-05-31T23:00:05.000Z","updated_at":"2024-06-21T00:09:20.000Z","dependencies_parsed_at":"2023-01-23T19:00:29.949Z","dependency_job_id":null,"html_url":"https://github.com/marzer/type_list","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marzer%2Ftype_list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marzer%2Ftype_list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marzer%2Ftype_list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marzer%2Ftype_list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marzer","download_url":"https://codeload.github.com/marzer/type_list/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248589504,"owners_count":21129627,"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":[],"created_at":"2024-10-14T09:55:26.062Z","updated_at":"2025-04-12T15:31:23.977Z","avatar_url":"https://github.com/marzer.png","language":"C++","funding_links":["https://github.com/sponsors/marzer"],"categories":[],"sub_categories":[],"readme":"# `mz::type_list` [![MIT license](docs/images/badge-license-MIT.svg)](./LICENSE) [![C++17](docs/images/badge-c++17.svg)][cpp_compilers] [![Sponsor](docs/images/badge-sponsor.svg)][sponsor] [![Gitter](docs/images/badge-gitter.svg)][gitter]\n\nA variadic 'type list' for performing operations on lists of types in metaprogramming contexts. Optimized to be much more compiler-friendly than `std::tuple`.\n\nSee [Compilation speed humps: std::tuple](https://marzer.github.io/md_blog_2021_05_31_compilation_speed_humps_std_tuple.html) for a write-up on the sorts of optimizations applied herein.\n\nRequires C++17.\n\n\u003cbr\u003e\n\n## Synopsis\n\n```cpp\nnamespace mz\n{\n\ttemplate \u003ctypename... T\u003e\n\tstruct type_list\n\t{\n\t\t// get the number of types in the list:\n\t\tstatic constexpr size_t length = sizeof...(T);\n\n\t\t// index of the first appearance of the specified type:\n\t\ttemplate \u003ctypename U\u003e\n\t\tstatic constexpr size_t index_of = /* ... */;\n\n\t\t// determine if a specified type appears in the list:\n\t\ttemplate \u003ctypename U\u003e\n\t\tstatic constexpr bool contains = /* ... */;\n\n\t\t// get a specific type:\n\t\ttemplate \u003csize_t Index\u003e\n\t\tusing select = /* T...[Index] */;\n\n\t\t// convenience alias for select\u003c0\u003e:\n\t\tusing first = select\u003c0\u003e;\n\n\t\t// convenience alias for select\u003c0\u003e when length == 1:\n\t\tusing type = select\u003c0\u003e;\n\n\t\t// get a 'slice' (sublist):\n\t\ttemplate \u003csize_t Start, size_t Length = (length - Start)\u003e\n\t\tusing slice = type_list\u003c/* ... */\u003e;\n\n\t\t// adding on to the beginning of the list:\n\t\ttemplate \u003ctypename... U\u003e\n\t\tusing prepend = type_list\u003cU..., T...\u003e;\n\n\t\t// adding on to the end of the list:\n\t\ttemplate \u003ctypename... U\u003e\n\t\tusing append = type_list\u003cT..., U...\u003e;\n\n\t\t// recursively flatten child sublists:\n\t\tusing flatten = type_list\u003c/* ... */\u003e;\n\n\t\t// remove all occurrences of the specified type:\n\t\ttemplate \u003ctypename U\u003e\n\t\tusing remove = type_list\u003c/* ... */\u003e;\n\t};\n\n\t// alias for a single-element list:\n\ttemplate \u003ctypename T\u003e\n\tusing type_tag = type_list\u003cT\u003e;\n}\n```\n\n\u003cbr\u003e\n\n## Usage\n\nThe library is a single header so the easiest way to use it is to drop [type_list.hpp] somewhere in your project.\n\nAlternatively you can add `include` to your include paths then `#include \u003cmz/type_list.hpp\u003e`\n\nThere is also support for use as a `meson.build` subproject.\n\n\u003cbr\u003e\n\n## Benchmarks\n\nSingle-threaded compilation of the example application on my Ryzen 3950X:\n\n|                | Clang 12     | GCC 10      | MSVC 19.29  |\n| -------------- | ------------ | ----------- | ----------- |\n| std::tuple     | 6.448s       | 3.185s      | 7.965s      |\n| mz::type_list  | 0.303s       | 0.407s      | 0.830s      |\n| speedup factor | 21.2x faster | 7.8x faster | 9.6x faster |\n\n\u003cbr\u003e\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n\n\u003cbr\u003e\n\n## Contributing\n\nThere are three ways you can contribute:\n\n1. Reporting bug or making feature requests [here](https://github.com/marzer/type_list/issues/new)\n2. Opening a pull request (⚠\u0026#xFE0F; _caveat - see below_)\n3. Becoming a [sponsor] ❤\u0026#xFE0F;\n\n### Pull requests\n\n`type_list.hpp` is programmatically extracted from a much larger project so I won't accept pull requests made for this repository directly; if you wish to contribute a bugfix or a feature, please find the type_list implementation [in this project](https://github.com/marzer/muu) and propose your changes there instead. I will then propagate them to this satellite library when they are merged.\n\n[type_list.hpp]: include/mz/type_list.hpp\n[license]: ./LICENSE\n[cpp_compilers]: https://en.cppreference.com/w/cpp/compiler_support\n[gitter]: https://gitter.im/marzer/community\n[sponsor]: https://github.com/sponsors/marzer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarzer%2Ftype_list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarzer%2Ftype_list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarzer%2Ftype_list/lists"}