
c++11
Douzi1024
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
深入学习c++--智能指针(二) weak_ptr (打破shared_ptr循环引用)
目录 1. 几种智能指针 1.1 weak_ptr 1.2 weak_ptr基本用法 1.3 解决类之间循环引用 1.4用 enable_shared_from_this从this转换到shared_ptr 1. 几种智能指针 1. auto_ptr: c++11中推荐不使用他(放弃) 2.shared_ptr:每添加一次引用 就+1,减少一次引用,就-1;做到指针进行共享 ...原创 2019-05-02 21:01:52 · 3068 阅读 · 0 评论 -
深入学习c++--智能指针(三) unique_ptr
目录 1. 几种智能指针 1.1 unique_ptr 1.2 注意 1.3 使用方式 1. 几种智能指针 1. auto_ptr: c++11中推荐不使用他(放弃) 2.shared_ptr:拥有共享对象所有权语义的智能指针 3.unique_ptr:拥有独有对象所有权语义的智能指针 4.weaked_ptr:到std::shared_ptr所管理对象的弱引...原创 2019-05-02 23:13:54 · 468 阅读 · 0 评论 -
深入学习c++--智能指针(四)--使用建议
1. 不要自己手动管理资源 2. 一个裸指针不要用两个shared_ptr管理,unique_ptr 3. 使用shared_ptr作为函数的接口,如果有可能用 const shared_ptr&的形式 4. shared_ptr weak_ptr和裸指针相比,会大很多,并且效率上会有影响,尤其在多线程模式下。时间也上也是 可以这么写: // 只进行一次new, 至少可以节...原创 2019-05-02 23:58:29 · 226 阅读 · 0 评论 -
深入学习c++--lambda函数
1. 简单使用 #include <iostream> #include <functional> using namespace std; struct Print { void operator()(int a, int b, int c) const { cout << "a " << a <<...原创 2019-05-03 15:42:12 · 316 阅读 · 0 评论 -
深入学习c++--智能指针(一) shared_ptr
目录 1. 几种智能指针 1.1 shared_ptr 1. 几种智能指针 1. auto_ptr: c++11中推荐不使用他 2.shared_ptr:每添加一次引用 就+1,减少一次引用,就-1;做到指针进行共享 3.unique_ptr:一个指针同时只能有一个使用者使用 4.weaked_ptr:与shared_ptr搭配使用 1.1 shared_ptr 参...原创 2019-04-30 00:17:45 · 516 阅读 · 0 评论 -
深入学习c++--多线程编程(二)【当线程间需要共享非const资源】
1. 遇到的问题 #include <iostream> #include <thread> #include <chrono> #include <future> #include <cmath> #include <vector> #include <cstdlib> using namespace st...原创 2019-05-06 18:52:01 · 283 阅读 · 0 评论 -
深入学习c++--多线程编程(三)thread的两种死法
1. 生成了一个线程,需要告诉编译器是否管理 必须告诉编译器是不管理还是管理,否则直接down了 #include <iostream> #include <thread> #include <chrono> #include <future> #include <atomic> #include <cmath> #i...原创 2019-05-09 23:28:20 · 249 阅读 · 0 评论