V2EX  ›  英汉词典

Move Constructor

释义 Definition

移动构造函数:C++ 中一种特殊的构造函数,用于从“将要被销毁/不再需要”的对象(右值或可移动对象)中转移资源所有权(如堆内存、文件句柄、缓冲区),以避免昂贵的深拷贝,提高性能。常见签名形如:T(T&& other)。(该术语主要用于 C++11 及以后)

发音 Pronunciation (IPA)

/ˈmuːv kənˈstrʌktər/

例句 Examples

A move constructor transfers resources from a temporary object instead of copying them.
移动构造函数会从临时对象转移资源,而不是进行拷贝。

When the vector grows, it may use the move constructor to relocate elements efficiently, reducing allocations and copy costs.
vector 扩容时,它可能使用移动构造函数高效地搬移元素,从而减少分配次数和拷贝开销。

词源 Etymology

move”源自古法语 movoir(移动、推动),进一步来自拉丁语 movere(移动);“constructor”来自拉丁语 *construct-*(建造、构成)。在编程语境中,“constructor”指“构造函数”。“move constructor”作为术语与C++11 引入的移动语义(move semantics)紧密相关,用“move”来强调“资源转移”而非“复制”。

相关词 Related Words

文学与经典出处 Literary & Notable Works

  • The C++ Programming Language(Bjarne Stroustrup):讨论 C++11 特性时涉及移动语义与相关构造行为
  • *Effective Modern C++*(Scott Meyers):多条准则专门讲解移动构造、std::move 与性能陷阱
  • C++ Primer(Lippman, Lajoie, Moo):在对象拷贝与资源管理章节中系统讲解移动构造
  • *ISO/IEC 14882 (C++ Standard)*:语言规范层面对移动构造函数与重载决议等作出定义
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1915 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 06:22 · PVG 14:22 · LAX 22:22 · JFK 01:22
♥ Do have faith in what you're doing.