跳转至

ev-abseil-variadic-compressed-tuple-003

字段 值
项目 abseil/abseil-cpp
固定 commit 2065f4ded055
路径 absl/container/internal/compressed_tuple.h
行段 L112-L121
特性 可变参数模板
许可证 Apache-2.0
代码来源 项目源码
级别 manual
审核 zyuhao7 @ 2026-10-27
测试代码 否
发现方式 manual

用法

用两个参数包按索引展开多重继承,把每个类型和值配对

为什么典型

类型包与索引包同时展开成基类列表,是参数包配合 index_sequence 的经典用法。

摘录

template <typename... Ts, size_t... I, bool ShouldAnyUseBase>
struct ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC
    CompressedTupleImpl<CompressedTuple<Ts...>, std::index_sequence<I...>,
                        ShouldAnyUseBase>
    // We use the dummy identity function through std::integral_constant to
    // convince MSVC of accepting and expanding I in that context. Without it
    // you would get:
    //   error C3548: 'I': parameter pack cannot be used in this context
    : Storage<Ts, std::integral_constant<size_t, I>::value,
              StorageTag<Ts...>>... {

备注

生产路径;CompressedTuple 用参数包把多个值压进空基类优化后的元组。

查看固定 commit 源码 · 返回证据索引