c++ - boost hana 将两个序列压缩到 map 中

标签 c++ boost boost-hana

static constexpr auto type_tuple_c = hana::tuple_t<T...>;
static constexpr auto idx_tuple_c = hana::tuple_c<std::size_t, 0, sizeof...(T)>;

我想将这两个大小相等的序列相互映射。但是,我似乎无法理解如何使用 hana::map 功能获得它:

static constexpr auto type_idx_map_c = hana::unpack(
    hana::zip_with(hana::make_pair, type_tuple_c, idx_tuple_c)
  , hana::make_map
);

无论我进行何种转换,我似乎都无法创建映射。我知道 map 要求其元素属于 Product 概念,但我似乎无法理解(甚至无法理解)关于压缩结构的行为。

有什么我可以做的,或者我做错了什么吗?

运行 gcc version 6.0.0 20160320hana version 0.7.0 last fetched today

最佳答案

I'd like to map these two sequences of equal sizes with each other.

这些序列通常大小不等。 type_tuple_c尺寸 sizeof...(T) ,但是 idx_tuple_c大小为 2 - 它只包含元素 hana::size_c<0>hana::size_c<sizeof...(T)> .

我认为就指数而言,您正在寻找的只是 std::make_index_sequence<sizeof...(T)>{} .这应该仍然适用于 Boost.Hana。

关于c++ - boost hana 将两个序列压缩到 map 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36535547/

相关文章:

c++ - 是否有适合 boost::uint64_t 的格式化程序与 snprintf 一起使用?

c++ - 使用 boost::locale/ICU 边界分析与中文

c++ - 如何对数字元组应用 Action 元组?

c++ - 以快速方式从矩阵中删除列 C++

c++ - 在析构函数中删除 []

c++ - 用于 FL SDK 和 VST 的优秀 C++ GUI 库

c++ - 使用 boost.hana 内省(introspection)结构定义

c++ - 使用 OpenCv 2.4.10 + Cuda 7.5 + W10 时不支持 GPU

c++ - 使用 C++ 在 Linux 中检查文件是否存在和文件权限的最佳方法是什么

c++ - 为什么 boost::hana::overload_t 不能成为类的成员