摘要: void *my_memcpy_byte(void *dst, const void *src, int n){ if (dst == NULL || src == NULL || n <= 0) return NULL; char * pdst = (char *)dst; char * psrc 阅读全文
posted @ 2019-10-08 20:33 一日一更 阅读(210) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <string> using namespace std; class String { public: String(const char* str = NULL);//通用构造函数,String("abc") String(const S 阅读全文
posted @ 2019-10-08 20:25 一日一更 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 1.9 再论shared_ptr 的线程安全 虽然我们借shared_ptr 来实现线程安全的对象释放,但是shared_ptr 本身不是100% 线程安全的。它的引用计数本身是安全且无锁的,但对象的读写则不是,因为shared_ptr 有两个数据成员,读写操作不能原子化。根据文档11,shared 阅读全文
posted @ 2019-10-08 20:21 一日一更 阅读(5798) 评论(0) 推荐(0) 编辑
摘要: 一、智能指针shared_ptr 智能指针主要有三种:shared_ptr,unique_ptr和weak_ptr。 shared_ptr shared_ptr是最常用的智能指针(项目中我只用过shared_ptr)。shared_ptr采用了引用计数器,多个shared_ptr中的T *ptr指向 阅读全文
posted @ 2019-10-08 20:03 一日一更 阅读(290) 评论(0) 推荐(0) 编辑