C++11 学习笔记-07.Spaces in Template Expressions

Spaces in Template Expressions

vector<list<int> >;   //可以在C++的版本,必须有空格
vector<list<int>>;//任何版本都可以这么编译通过了

nullptr and std::nullptr_t

C++11让我们使用nullptr 代替0或者NULL

void f(int)
void f(void*)
f(0);//calls f(int)
f(NULL);//call f(int) 如果NULL是0,其他的就不知道了
f(nullptr);//calls f(void*)

\include\stddef

typedef deltype(nullptr) nullptr_t;

Automatic Type Deduction whit auto

auto i = 42;//i是int类型
double f()
auto d = f();//d是doublue类型
  • 好用的写法
vector<string> v;
...
auto pos = v.begin();// pos 的类型是vector<string>::iterator

auto l =(int x)->bool{}; //l是一个lambad表达式
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章