C++11学习
简单应用C++11的部分特性
wangshenqiang
这个作者很懒,什么都没留下…
展开
-
C++11学习笔记 -- move、auto、decltype、for
#include <iostream>#include <string>#include <vector>#include <cstring>#include <cassert> #include <typeinfo>using namespace std;//C++11 右值引用和void std::move()函数//右值:在 = 的右边,没名称,没法取地址,只是一个字面值或临时变量//左值:在 = 的左边.原创 2022-01-11 17:25:16 · 336 阅读 · 0 评论 -
C++11学习笔记 -- Lambda
#include <iostream>using namespace std;template <typename Func, typename A, typename B>void templetePrint(Func func, A a, B b){ func(a,b);}void testLambda(){ //[]默认不捕获外部定义的变量 auto funcPrint = [](int a,int b) { cout << "fun.原创 2022-01-14 11:17:24 · 118 阅读 · 0 评论 -
C++11学习笔记 -- thread&mutex
#include <iostream>#include <thread>#include <chrono>#include <mutex>/*****************************************************************************多线程 & 互斥锁多线程1. 创建线程后,一定要记得释放线程2. 多线程中能不共享的资源,就不共享3. 共享的资源注意,各线程访问时的安全.原创 2022-01-25 11:22:27 · 434 阅读 · 0 评论 -
C++11学习笔记 -- 智能指针
#include <memory>#include <iostream>/************************************************************************************使用智能指针的注意点: 1. 绝对不要自己手动管理堆空间(delete、delete[]) 2. 初始化智能指针时尽可能使用 std::make_shared 3. 不要用一个裸指针去构造两个智能指针对象(两个单独构造的对象的.原创 2022-01-13 17:42:59 · 244 阅读 · 0 评论