V2EX  ›  英汉词典

Smart Pointer

释义 Definition

(计算机)智能指针:一种“像指针一样使用”的对象,用来自动管理动态分配的内存/资源,在合适的时机释放资源,从而减少内存泄漏悬空指针等问题。常见于 C++(如 std::unique_ptrstd::shared_ptr)。

发音 Pronunciation (IPA)

/smɑːrt ˈpɔɪntər/

例句 Examples

A smart pointer can free memory automatically.
智能指针可以自动释放内存。

In modern C++, using a smart pointer helps ensure exception-safe resource management and prevents memory leaks in complex code paths.
在现代 C++ 中,使用智能指针有助于确保异常情况下的资源管理安全,并在复杂的代码路径中防止内存泄漏。

词源 Etymology

“smart pointer”由 smart(智能的) + pointer(指针)构成,意指这种指针“更聪明”:它不仅保存地址,还把资源生命周期管理封装起来。该概念在 C++ 社区中随着 RAII(资源获取即初始化)思想普及而广泛使用,并在标准库中以 std::unique_ptrstd::shared_ptr 等形式成为主流。

相关词 Related Words

文学作品/经典著作 Literary Works

  • The C++ Programming Language(Bjarne Stroustrup)
  • *Effective C++*(Scott Meyers)
  • *Effective Modern C++*(Scott Meyers)
  • C++ Primer(Lippman, Lajoie, Moo)
  • Modern C++ Design(Andrei Alexandrescu)
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   795 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 19:18 · PVG 03:18 · LAX 11:18 · JFK 14:18
♥ Do have faith in what you're doing.