Last active
November 12, 2015 00:45
-
-
Save ricejasonf/b5547a9a4a11b46619ed to your computer and use it in GitHub Desktop.
Hana map thing that doesn't compile on my linux box.
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<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