跳转至

ev-abseil-ctad-overload-003

字段 值
项目 abseil/abseil-cpp
固定 commit 2065f4ded055
路径 absl/functional/overload.h
行段 L63-L67
特性 类模板实参推导(CTAD)
许可证 Apache-2.0
代码来源 项目源码
级别 manual
审核 zyuhao7 @ 2026-10-26
测试代码 否
发现方式 manual

用法

为变参聚合类型提供显式推导指引,补足 C++17 缺少的聚合 CTAD

为什么典型

C++20 才支持聚合类模板的实参推导;C++17 代码必须手写指引,注释直接说明了这层兼容原因。

摘录

// Before C++20, which added support for CTAD for aggregate types, we must also
// teach the compiler how to deduce the template arguments for Overload.
//
template <typename... T>
Overload(T...) -> Overload<T...>;

备注

生产头文件;显式指引与 C++20 聚合 CTAD 的分界点。

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