Skip to content

Instantly share code, notes, and snippets.

@ricejasonf
Last active November 12, 2015 00:45
Show Gist options
  • Save ricejasonf/b5547a9a4a11b46619ed to your computer and use it in GitHub Desktop.
Save ricejasonf/b5547a9a4a11b46619ed to your computer and use it in GitHub Desktop.
Hana map thing that doesn't compile on my linux box.
#include<boost/hana.hpp>
#include<vector>
#include<iostream>
namespace hana = boost::hana;
struct Tag1 {};
struct Tag2 {};
struct Tag3 {};
using Vector = std::vector<int>;
template<int i>
auto buildLargeMap() {
return hana::transform(
hana::unpack(hana::range_c<int, 0, i>, hana::make_tuple),
[](auto x) {
return hana::make_pair(x, Vector{});
});
}
template<int i>
auto buildLargeTuple() {
return hana::transform(
hana::unpack(hana::range_c<int, 0, i>, hana::make_tuple),
[](auto x) {
return Vector{};
});
}
int main() {
constexpr auto t = hana::tuple_t<Vector, Vector, Vector>;
std::cout << sizeof(hana::type_c<Tag1>);
//1
std::cout << '\n';
std::cout << sizeof(5);
//4
std::cout << '\n';
std::cout << sizeof(hana::make_pair(hana::type_c<Tag1>, 5));
//8
std::cout << '\n';
std::cout << sizeof(buildLargeTuple<500>());
//12000
std::cout << '\n';
std::cout << sizeof(buildLargeMap<500>());
//16008
std::cout << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment