升压为什么指针范围 [英] Why scoped pointers in boost

查看:204
本文介绍了升压为什么指针范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是范围指针的目的是什么?我的理解,范围指针管理code块的内存中。如果我想要一个块中声明一个变量,我可以宣布它在堆栈上,而不必担心清洁。

What is the objective of scoped pointer? to my understanding, the scoped pointer manages the memory within a block of code. If i want to declare a variable within a block , i can just declare it on a stack and not worry about cleaning.

推荐答案

如果它是动态的尺寸或类型。此外,作用域的指针可以交换,并在C ++ 11 的unique_ptr 可以移动,所以他们没有严格的范围。

Not if it's of dynamic size or type. In addition, scoped pointers can be swapped, and in C++11 unique_ptr can be moved, so they're not strictly scoped.

这篇关于升压为什么指针范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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