#include #include struct pos2d{ int x; int
y;};using namespace std;int main(){
//boost::interprocess::shared_memory_object类是按照单个字节的方式读写共享内存,用...
分类:
其他好文 时间:
2014-06-07 03:57:20
阅读次数:
277
用于大型程序的工具--异常处理[续3]九、auto_ptr类[接上]5、auto_ptr对象的复制和赋值是破坏性操作 auto_ptr和内置指针对待复制和赋值有非常关键的区别。当复制auto_ptr对象或者将它的值赋给其他auto_ptr对象的时候,将基础对象的所有权从原来的auto_ptr对象转给副本,原来的auto_ptr对象重置为未绑定状态。 auto_ptr strPtr1(new ...
分类:
编程语言 时间:
2014-06-05 08:34:36
阅读次数:
366
/src/graphlab-master/deps/local/include/boost/atomic/atomic.hpp:166:16:
error: ‘uintptr_t’ was not declared in this scope typedef atomic
atomic_uintpt...
分类:
其他好文 时间:
2014-05-31 11:53:03
阅读次数:
345
#include #include #include #include using
namespace std;int main(){
//boost::interprocess::shared_memory_object类是按照单个字节的方式读写共享内存,用起来不方便 boost::i...
分类:
其他好文 时间:
2014-05-30 12:56:14
阅读次数:
225
struct shareDataEx : shareData{ int index; int
total_size;};typedef managed_shared_memory::segment_manager segment_manager_t;
//段管理器type...
分类:
其他好文 时间:
2014-05-30 11:23:53
阅读次数:
267
一、简介由于 C++ 语言没有自动内存回收机制,程序员每次 new 出来的内存都要手动
delete。程序员忘记 delete,流程太复杂,最终导致没有 delete,异常导致程序过早退出,没有执行 delete
的情况并不罕见。用智能指针便可以有效缓解这类问题,本文主要讲解参见的智能指针的用法。包...
分类:
编程语言 时间:
2014-05-28 16:51:32
阅读次数:
354
boost 的smart_ptr 库中含有好几种智能指针,大家用的最多的应该是shared_ptr
,为啥呢?好用,不用管他啥时候会自动删除等等,而且拷贝和复制都很到位,
但实际上,这个库也有问题,连城写过一片文章,详细介绍了boost::shared_ptr库的四宗罪,不过我觉得有的问题,实际上不...
分类:
其他好文 时间:
2014-05-28 03:30:26
阅读次数:
343
起:C++98标准加入auto_ptr,即智能指针,C++11加入shared_ptr和weak_ptr两种智能指针,先从auto_ptr的定义学习一下auto_ptr的用法。template class
auto_ptr { // wrap an object pointer to ensure....
分类:
编程语言 时间:
2014-05-27 16:13:40
阅读次数:
440
boost中lambda表达式中调用占位符参数的函数的方法...
分类:
其他好文 时间:
2014-05-25 21:56:52
阅读次数:
239
The Leak of the Memory in C++
In this chaper I will introduce a new smart pointer which is scoped_ptr;
It likes auto_ptr but better. When peopel use auto_ptr, sometimes they forget
that auto_...
分类:
编程语言 时间:
2014-05-25 07:03:10
阅读次数:
373