Created
October 6, 2020 21:05
-
-
Save notfoundry/55f71c525db1778bfe78f2ac6a30fa5c to your computer and use it in GitHub Desktop.
Lift heterogenous eager C++ metafunction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "lift.hpp" | |
| constexpr auto make_array = META_LIFT(std::array, (class, int)); | |
| using array_of_5_ints = decltype(make_array.template operator()<int, 5>()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <order/interpreter.h> | |
| #define META_LIFT(fn, args) \ | |
| ORDER_PP(8let((8S, 8seq_pair_with(8pair, \ | |
| 8tuple_to_seq(8(args)), \ | |
| 8seq_map(8compose(8paste(8(X)), 8to_lit), \ | |
| 8seq_iota(0, 8tuple_size(8(args)))))), \ | |
| 8do(\ | |
| 8put(8([]<)), \ | |
| 8seq_for_each_with_delimiter(8apply(8emit), 8emit_comma, 8S), \ | |
| 8put(8(>() constexpr -> fn<)), \ | |
| 8seq_for_each_with_delimiter(8compose(8put, 8tuple_at_1), 8emit_comma, 8S), \ | |
| 8put(8(> {throw;}))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment