{"id":13591911,"url":"https://github.com/brunocodutra/metal","last_synced_at":"2025-04-07T10:27:57.949Z","repository":{"id":28184543,"uuid":"31686207","full_name":"brunocodutra/metal","owner":"brunocodutra","description":"Love template metaprogramming","archived":false,"fork":false,"pushed_at":"2022-04-10T21:40:42.000Z","size":3696,"stargazers_count":329,"open_issues_count":7,"forks_count":24,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-31T09:04:29.009Z","etag":null,"topics":["cpp","cpp11","metaprogramming","mpl","single-header","template-metaprogramming","templates"],"latest_commit_sha":null,"homepage":"https://brunocodutra.github.io/metal/","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/brunocodutra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-04T23:47:59.000Z","updated_at":"2025-03-02T05:38:06.000Z","dependencies_parsed_at":"2022-08-08T13:00:24.653Z","dependency_job_id":null,"html_url":"https://github.com/brunocodutra/metal","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunocodutra%2Fmetal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunocodutra%2Fmetal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunocodutra%2Fmetal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunocodutra%2Fmetal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brunocodutra","download_url":"https://codeload.github.com/brunocodutra/metal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247634790,"owners_count":20970602,"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":["cpp","cpp11","metaprogramming","mpl","single-header","template-metaprogramming","templates"],"created_at":"2024-08-01T16:01:03.599Z","updated_at":"2025-04-07T10:27:57.926Z","avatar_url":"https://github.com/brunocodutra.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# Metal [![version]][semver] [![godbolt.badge]][godbolt.metal]\n\nMetal is a single-header C++11 library designed to make you love template\nmetaprogramming.\n\n## Overview\n\n```.cpp\n#include \u003cmetal.hpp\u003e\n\n// First we need some Values\nunion x { char payload[10]; };\nclass y { public: char c; };\nstruct z { char c; int i; };\n\n// ... from which we construct some Lists\nusing l0 = metal::list\u003c\u003e;\nusing l1 = metal::prepend\u003cl0, x\u003e;\nusing l2 = metal::append\u003cl1, z\u003e;\nusing l3 = metal::insert\u003cl2, metal::number\u003c1\u003e, y\u003e;\n\nstatic_assert(metal::same\u003cl1, metal::list\u003cx\u003e\u003e::value, \"\");\nstatic_assert(metal::same\u003cl2, metal::list\u003cx, z\u003e\u003e::value, \"\");\nstatic_assert(metal::same\u003cl3, metal::list\u003cx, y, z\u003e\u003e::value, \"\");\n\n// Lists are versatile, we can check their sizes...\nstatic_assert(metal::size\u003cl0\u003e::value == 0, \"\");\nstatic_assert(metal::size\u003cl1\u003e::value == 1, \"\");\nstatic_assert(metal::size\u003cl2\u003e::value == 2, \"\");\nstatic_assert(metal::size\u003cl3\u003e::value == 3, \"\");\n\n// retrieve their elements...\nstatic_assert(metal::same\u003cmetal::front\u003cl3\u003e, x\u003e::value, \"\");\nstatic_assert(metal::same\u003cmetal::back\u003cl3\u003e, z\u003e::value, \"\");\nstatic_assert(metal::same\u003cmetal::at\u003cl3, metal::number\u003c1\u003e\u003e, y\u003e::value, \"\");\n\n// count those that satisfy a predicate...\nstatic_assert(metal::count_if\u003cl3, metal::trait\u003cstd::is_class\u003e\u003e::value == 2, \"\");\nstatic_assert(metal::count_if\u003cl3, metal::trait\u003cstd::is_union\u003e\u003e::value == 1, \"\");\n\n// We can create new Lists by removing elements...\nusing l0_ = metal::drop\u003cl3, metal::number\u003c3\u003e\u003e;\nusing l1_ = metal::take\u003cl3, metal::number\u003c1\u003e\u003e;\nusing l2_ = metal::erase\u003cl3, metal::number\u003c1\u003e\u003e;\n\nstatic_assert(metal::same\u003cl0, l0_\u003e::value, \"\");\nstatic_assert(metal::same\u003cl1, l1_\u003e::value, \"\");\nstatic_assert(metal::same\u003cl2, l2_\u003e::value, \"\");\n\n// by reversing the order of elements...\nstatic_assert(metal::same\u003cmetal::reverse\u003cl0\u003e, metal::list\u003c\u003e\u003e::value, \"\");\nstatic_assert(metal::same\u003cmetal::reverse\u003cl1\u003e, metal::list\u003cx\u003e\u003e::value, \"\");\nstatic_assert(metal::same\u003cmetal::reverse\u003cl2\u003e, metal::list\u003cz, x\u003e\u003e::value, \"\");\nstatic_assert(metal::same\u003cmetal::reverse\u003cl3\u003e, metal::list\u003cz, y, x\u003e\u003e::value, \"\");\n\n// by transforming the elements...\nusing l2ptrs = metal::transform\u003cmetal::lazy\u003cstd::add_pointer\u003e, l2\u003e;\nusing l3refs = metal::transform\u003cmetal::lazy\u003cstd::add_lvalue_reference\u003e, l3\u003e;\n\nstatic_assert(metal::same\u003cl2ptrs, metal::list\u003cx*, z*\u003e\u003e::value, \"\");\nstatic_assert(metal::same\u003cl3refs, metal::list\u003cx\u0026, y\u0026, z\u0026\u003e\u003e::value, \"\");\n\n// even by sorting them...\ntemplate\u003cclass x, class y\u003e\nusing smaller = metal::number\u003c(sizeof(x) \u003c sizeof(y))\u003e;\n\nusing sorted = metal::sort\u003cl3, metal::lambda\u003csmaller\u003e\u003e;\n\nstatic_assert(metal::same\u003csorted, metal::list\u003cy, z, x\u003e\u003e::value, \"\");\n\n// that and much more!\n```\n\n## Quick Start\n\n1. Download [metal.hpp][releases]\n2. `#include \u003c/path/to/metal.hpp\u003e`\n3. Love template metaprogramming\n\n## Blazingly Fast\n\nYou don't need to just take my word for it, see for yourself at [metaben.ch].\n\n## Portable\n\nMetal is known to work on GCC, Clang, Visual Studio, and Xcode.\n\n## Documentation\n\nThe complete up-to-date documentation is available [online][documentation].\n\n\n## License\n\nThis project is licensed under the [MIT][license].\n\n[version]:          https://badge.fury.io/gh/brunocodutra%2Fmetal.svg\n[semver]:           https://semver.org\n\n[godbolt.metal]:    https://godbolt.org/z/9Gr5bP5cd\n[godbolt.badge]:    https://img.shields.io/badge/try%20it-on%20godbolt-222266.svg\n\n[CMake]:            https://cmake.org/\n[Doxygen]:          https://doxygen.org/\n[metaben.ch]:       http://metaben.ch/\n\n[license]:          https://github.com/brunocodutra/metal/blob/master/LICENSE\n[releases]:         https://github.com/brunocodutra/metal/releases\n[documentation]:    https://brunocodutra.github.io/metal\n[examples]:         https://brunocodutra.github.io/metal/#examples\n[SFINAE]:           https://brunocodutra.github.io/metal/#SFINAE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunocodutra%2Fmetal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrunocodutra%2Fmetal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunocodutra%2Fmetal/lists"}