-
new (std::nothrow)A()当内存不足时,返回null
-
std::function<A*(int)>代表一个可调用对象,接受1个int的参数,返回值是A*
-
对于c++ 对象的方法,可以通过std::bind 转换为可调用对象
A *a = new A();
std::function<A*(int)> f1 = std::bind(&A::test,a);
-
lambda表达式,[ capture ] ( params ) -> ret { body } //ret表示返回类型
std::function<void(Node*)> func =[this, tool](Node *node){}; [this,tool]表示参数捕获,传了this之后,可以访问this下的方法和变量,也可以传入局部变量tool。 有以下几种捕获方式[x] 使用x的副本
[&x] 使用x的引用 [=] 使用外部作用域的所有变量的副本 [&] 使用外部作用域的所有变量的引用 [=,&x] 使用外部作用域的所有变量的副本,但使用x的引用 [this] 使用当前对象的this指针 -
override显示表明是从父类重写的,final加在类声明上表明类不可被继承,加载方法上面表明方法不能被子类重写。
-
右值引用。避免重复拷贝,采用内存交换的方式,可以配合std::move来使用。