跳转至

ev-mold-structured-bindings-insert-001

字段 值
项目 rui314/mold
固定 commit 27162691b71a
路径 src/output-chunks.cc
行段 L515-L518
特性 结构化绑定
许可证 MIT
代码来源 项目源码
级别 manual
审核 zyuhao7 @ 2026-10-25
测试代码 否
发现方式 tree-sitter

用法

用结构化绑定同时接收 insert 返回的迭代器与插入标志

为什么典型

insert 返回 pair;直接命名 it 与 inserted,后续代码不必依赖 .first/.second 的位置含义。

摘录

      auto [it, inserted] = map.insert({chunk->name, offset});
      chunk->shdr.sh_name = it->second;
      if (inserted)
        offset += chunk->name.size() + 1;

备注

生产路径;绑定名直接对应元素位置与插入状态。

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