#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`不是序列?