#include <string>
#include <utility>
#include <vector>
#include <boost/hana.hpp>
namespace hana = boost::hana;
template <typename ...T>
void indexed_T_work(T&& ...args)
{
auto indices = hana::range_c<std::size_t, 0, sizeof...(T)>;
auto types = hana::make_tuple(std::forward<T>(args)...);
hana::for_each(
hana::zip(indices, types)
, [](auto&& pair_) { /* Do index-dependent work with each `T` */ }
);
}
int main()
{
indexed_T_work(5, 13, std::vector<std::string>{}, 32.f, 42, "foo");
}
我想在hana::tuple
和hana::range_c
,但hana::range_c
使用hana::zip
不被认为是序列,这是hana::zip
的要求。这个决定背后的推理是什么?我如何(习惯性地)在尊重这个决定的同时实现我的目标?为什么`boost :: hana :: range_c`不是序列?