由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 一个小问题
相关主题
请问delete的问题其实很多C++11的feature都是从TR1, Boost,过来的老feature了
咋用python做一个3D surface plot? 请教c++ 里用到pointer 的地方我们尽可能用smart pointer吗?
一个简单的小问题copy constructor 问题
c+= 怎么实现 hashtable 的?一个C#使用C++.NET类库的问题
1999年出版的C,C++,Java语言教程过期了吗??delete this problem
这里的人用BOOST都是用来做什么?C 多线程的一个问题
about STL functor and function pointers问个C++中重复删除指针的问题
C++ Q05: pointer to constant variable作为返回值得实参是用指针还是引用比较好?
相关话题的讨论汇总
话题: sample1话题: stl话题: thus话题: ptr话题: 解释
进入Programming版参与讨论
1 (共1页)
s******y
发帖数: 68
1
所有种类的smart pointer 都不可以做STL的参数?
还是只是smart pointer里的几种 不可以做STL的参数?
能说一下并给一些解释吗
谢谢
c*****e
发帖数: 11
2
boost的智能指针可以:)
而且很好用
stl的智能指针不能

【在 s******y 的大作中提到】
: 所有种类的smart pointer 都不可以做STL的参数?
: 还是只是smart pointer里的几种 不可以做STL的参数?
: 能说一下并给一些解释吗
: 谢谢

s*******e
发帖数: 28
3
auto_ptr in the Standard library doesn't have the normal copy behavior
because of the feature of transfer of ownership. Thus it can't be used
in the containers in STL which require normal copy function.
However, shared_ptr in TR1 or Boost is one smart pointer that uses reference
count and has normal behavior of copying. It can be used for STL.
y*h
发帖数: 107
4

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
解释解释这句吧, 没看懂.
Thus it can't be used
reference

【在 s*******e 的大作中提到】
: auto_ptr in the Standard library doesn't have the normal copy behavior
: because of the feature of transfer of ownership. Thus it can't be used
: in the containers in STL which require normal copy function.
: However, shared_ptr in TR1 or Boost is one smart pointer that uses reference
: count and has normal behavior of copying. It can be used for STL.

s*******e
发帖数: 28
5
std::auto_ptr sample1 = new T();
// sample1 points to or owns the resource allocated by new.
std::auto_ptr sample2 = sample1;
// While you copy or assign an auto_ptr, the resource that is owned by
sample1 early is now transfered to sample2. And sample1 = NULL.
//It is unlike the normal copy process where sample1 and sample2 both should
point to and share the resource.
1 (共1页)
进入Programming版参与讨论
相关主题
作为返回值得实参是用指针还是引用比较好?1999年出版的C,C++,Java语言教程过期了吗??
再问一个弱问题:为什么程序地址0-0x08000000是不可用的 (转载)这里的人用BOOST都是用来做什么?
一道面试题about STL functor and function pointers
dereference a NULL pointer in CC++ Q05: pointer to constant variable
请问delete的问题其实很多C++11的feature都是从TR1, Boost,过来的老feature了
咋用python做一个3D surface plot? 请教c++ 里用到pointer 的地方我们尽可能用smart pointer吗?
一个简单的小问题copy constructor 问题
c+= 怎么实现 hashtable 的?一个C#使用C++.NET类库的问题
相关话题的讨论汇总
话题: sample1话题: stl话题: thus话题: ptr话题: 解释