侯捷C++(C++标准11-14)
第一讲 语言
C++2.0 新的标准库
#include <iostream> using namespace std; int main() { cout << __cplusplus << endl; return 0; }
确认支持C++11
(1)Variadic Templates(参数数量不定的模板)
#include <iostream> #include <bitset> using namespace std; void print() { cout<<"end"<<endl; } template <typename T,typename... Types> void print(const T& firstArg,const Types&... args) { cout<<firstArg<<endl; print(args...); } int main() { print(7.5,"hello",bitset<16>(377),42); return 0; }
nullptr代替0或者NULL
auto
一致性初始化 使用大括号
初始化列表
explicit
for(decl:coll)
{
statement
}
=default
=delete
Alias Template 化名模板
template <typename T>
using Vec = std::vector<T,MyAlloc<T>>
Type Alias
noexcept
override
final
dectype
lambdas
[]() mutable throwSpec ->retType{...}
第二讲 标准库
右值引用
move
array
hashtable
hashfunction
tuple