全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Smart pointer, unique pointer, unique ownership?

又称: smart pointer · unique pointer · unique ownership

Definition 2.13 University Computer Science — Year 2 · 第 2 章 — Copying, Moving and Smart Pointers

A smart pointer is a class that holds a pointer to a heap object and releases the object in its destructor. The unique pointer std::unique_ptr<T> is the sole owner of its object (unique ownership): it cannot be copied, it can be moved, which transfers the ownership and leaves the source null, and its destructor deletes the object if it holds one. std::make_unique<T>(args) allocates and constructs the object.

在原文中阅读 →