如何处理unique_ptr? [英] How to dispose of unique_ptr?

查看:33
本文介绍了如何处理unique_ptr?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在看一些 arduino 代码,上面写着:

I was looking at some arduino code which said :

std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);

通常使用 make_unique 创建唯一指针.

Normally a unique pointer is created using make_unique.

所以我想知道我需要做什么来处理这个指针?

So I was wondering what I need to do to dispose of this pointer ?

推荐答案

我认为 make_unique 是在c++14 中引入的,在此之前,您发布的systax 是创建unique_ptr 的标准方式.您不需要做任何事情来处理原始指针和 unique_ptr.

I think make_unique is introduced in c++14, before that, the systax you posted is the standard way to create a unique_ptr. You don't need to do anything to dispose the raw pointer and unique_ptr.

这篇关于如何处理unique_ptr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆