gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:28:30 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com