Skip to content

Instantly share code, notes, and snippets.

@notfoundry
Created October 6, 2020 21:05
Show Gist options
  • Select an option

  • Save notfoundry/55f71c525db1778bfe78f2ac6a30fa5c to your computer and use it in GitHub Desktop.

Select an option

Save notfoundry/55f71c525db1778bfe78f2ac6a30fa5c to your computer and use it in GitHub Desktop.
Lift heterogenous eager C++ metafunction
#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>());
#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