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

查看:80
本文介绍了如何处理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天全站免登陆