Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brunocodutra/metal
Love template metaprogramming
https://github.com/brunocodutra/metal
cpp cpp11 metaprogramming mpl single-header template-metaprogramming templates
Last synced: about 14 hours ago
JSON representation
Love template metaprogramming
- Host: GitHub
- URL: https://github.com/brunocodutra/metal
- Owner: brunocodutra
- License: mit
- Created: 2015-03-04T23:47:59.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-04-10T21:40:42.000Z (almost 3 years ago)
- Last Synced: 2025-01-29T14:07:14.318Z (8 days ago)
- Topics: cpp, cpp11, metaprogramming, mpl, single-header, template-metaprogramming, templates
- Language: C++
- Homepage: https://brunocodutra.github.io/metal/
- Size: 3.52 MB
- Stars: 327
- Watchers: 18
- Forks: 23
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Metal [![version]][semver] [![godbolt.badge]][godbolt.metal]
Metal is a single-header C++11 library designed to make you love template
metaprogramming.## Overview
```.cpp
#include// First we need some Values
union x { char payload[10]; };
class y { public: char c; };
struct z { char c; int i; };// ... from which we construct some Lists
using l0 = metal::list<>;
using l1 = metal::prepend;
using l2 = metal::append;
using l3 = metal::insert, y>;static_assert(metal::same>::value, "");
static_assert(metal::same>::value, "");
static_assert(metal::same>::value, "");// Lists are versatile, we can check their sizes...
static_assert(metal::size::value == 0, "");
static_assert(metal::size::value == 1, "");
static_assert(metal::size::value == 2, "");
static_assert(metal::size::value == 3, "");// retrieve their elements...
static_assert(metal::same, x>::value, "");
static_assert(metal::same, z>::value, "");
static_assert(metal::same>, y>::value, "");// count those that satisfy a predicate...
static_assert(metal::count_if>::value == 2, "");
static_assert(metal::count_if>::value == 1, "");// We can create new Lists by removing elements...
using l0_ = metal::drop>;
using l1_ = metal::take>;
using l2_ = metal::erase>;static_assert(metal::same::value, "");
static_assert(metal::same::value, "");
static_assert(metal::same::value, "");// by reversing the order of elements...
static_assert(metal::same, metal::list<>>::value, "");
static_assert(metal::same, metal::list>::value, "");
static_assert(metal::same, metal::list>::value, "");
static_assert(metal::same, metal::list>::value, "");// by transforming the elements...
using l2ptrs = metal::transform, l2>;
using l3refs = metal::transform, l3>;static_assert(metal::same>::value, "");
static_assert(metal::same>::value, "");// even by sorting them...
template
using smaller = metal::number<(sizeof(x) < sizeof(y))>;using sorted = metal::sort>;
static_assert(metal::same>::value, "");
// that and much more!
```## Quick Start
1. Download [metal.hpp][releases]
2. `#include `
3. Love template metaprogramming## Blazingly Fast
You don't need to just take my word for it, see for yourself at [metaben.ch].
## Portable
Metal is known to work on GCC, Clang, Visual Studio, and Xcode.
## Documentation
The complete up-to-date documentation is available [online][documentation].
## License
This project is licensed under the [MIT][license].
[version]: https://badge.fury.io/gh/brunocodutra%2Fmetal.svg
[semver]: https://semver.org[godbolt.metal]: https://godbolt.org/z/9Gr5bP5cd
[godbolt.badge]: https://img.shields.io/badge/try%20it-on%20godbolt-222266.svg[CMake]: https://cmake.org/
[Doxygen]: https://doxygen.org/
[metaben.ch]: http://metaben.ch/[license]: https://github.com/brunocodutra/metal/blob/master/LICENSE
[releases]: https://github.com/brunocodutra/metal/releases
[documentation]: https://brunocodutra.github.io/metal
[examples]: https://brunocodutra.github.io/metal/#examples
[SFINAE]: https://brunocodutra.github.io/metal/#SFINAE