ev-abseil-bit-cast-alias-002¶
| 字段 | 值 |
|---|---|
| 项目 | abseil/abseil-cpp |
| 固定 commit | 2065f4ded055 |
| 路径 | absl/base/casts.h |
| 行段 | L168-L175 |
| 特性 | std::bit_cast |
| 许可证 | Apache-2.0 |
| 代码来源 | 项目源码 |
| 级别 | manual |
| 审核 | zyuhao7 @ 2026-10-26 |
| 测试代码 | 否 |
| 发现方式 | regex |
用法¶
特性可用时把 absl::bit_cast 直接别名到 std::bit_cast
为什么典型¶
库保留旧接口名,但让 C++20 用户落到标准实现;注释明确写出回退实现的额外约束。
摘录¶
// The requirements of `absl::bit_cast` are more strict than that of
// `std::bit_cast` unless compiler support is available. Specifically, without
// compiler support, this implementation also requires `Dest` to be
// default-constructible. In C++20, `absl::bit_cast` is replaced by
// `std::bit_cast`.
#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L
using std::bit_cast;
备注¶
生产路径;别名依赖 __cpp_lib_bit_cast 特性测试宏。