【发布时间】:2016-01-10 22:44:20
【问题描述】:
我在两个月前发现了 boost::hana。看起来很强大,所以我决定看看。 从文档中我看到了这个例子:
std::string s;
hana::int_c<10>.times([&]{ s += "x"; });
相当于:
s += "x"; s += "x"; ... s += "x"; // 10 times
我想知道是否有可能(如果是的话,如何)这样写:
std::string s;
std::array<int, 10> xs = {1, 3, 5, ...};
hana::int_c<10>.times([&](int i){ s += std::to_string(xs[i]) + ","; });
一种在编译时的“解包”,甚至:
myfunction( hana::unpack<...>( xs ) );
【问题讨论】:
标签: c++ boost c++14 boost-hana