2018年8月20日

C++11 占位符placeholders和函数bind用法

摘要: #include #include #include using namespace std; using namespace std::placeholders; void test(int i, double d, const string &s) { cout fp; string s = "foo"; int a = 3; double b =... 阅读全文

posted @ 2018-08-20 13:45 奔跑吧,蜗牛! 阅读(6135) 评论(0) 推荐(0) 编辑

C++11 function函数用法

摘要: // C++11 function #include void print_num(int i) { std::cout getSum = [&](const int &nI1, const int &nI2) { int nSum = nI1 + nI2; std::cout f_display_42 = []() { print_num(42); }; f_displa... 阅读全文

posted @ 2018-08-20 13:25 奔跑吧,蜗牛! 阅读(10179) 评论(0) 推荐(1) 编辑

placement new的用法及用途

摘要: 什么是placement new?所谓placement new就是在用户指定的内存位置上构建新的对象,这个构建过程不需要额外分配内存,只需要调用对象的构造函数即可。举例来说:class foo{};foo* pfoo = new foo;pfoo指向的对象的地址你是不能决定的,因为new已经为你做 阅读全文

posted @ 2018-08-20 12:03 奔跑吧,蜗牛! 阅读(6870) 评论(0) 推荐(2) 编辑

导航