什么是std :: unique_ptr :: get的点 [英] what's the point of std::unique_ptr::get
本文介绍了什么是std :: unique_ptr :: get的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
不是 std :: unique_ptr :: get
首先失去了一个unique_ptr的目的?
我希望这个函数改变它的状态,所以没有更多的指针。
实际有用的使用std :: unique_ptr :: get?
Doesn't std::unique_ptr::get
defeat the purpose of having a unique_ptr in the first place?
I would have expected this function to change its state so it holds no more pointer.
Is there an actual useful use of std::unique_ptr::get?
推荐答案
需要传递原始指针,说,一个C函数:
You use it every time you need to pass raw pointer to, say, a C function:
std::unique_ptr<char[]> buffer( new char[1024] );
// ... fill the buffer
int rc = ::write( fd, buffer.get(), len );
这篇关于什么是std :: unique_ptr :: get的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文