摘要: Rvalue references (右值引用) and Move Semantics Rvalue references are a new reference type introduced in C++0x that help solve the problem of unnecessary 阅读全文
posted @ 2020-11-19 15:31 Codroc 阅读(99) 评论(0) 推荐(0) 编辑
摘要: range-based for statement for(decl : coll){ // decl:声明 coll:容器 statement } for(int i : {2, 3, 4, 5, 6}){ cout << i << endl; } vector<double> vec; ··· 阅读全文
posted @ 2020-11-19 11:50 Codroc 阅读(86) 评论(0) 推荐(0) 编辑
摘要: Automatic Type Deduction with auto With C++11, you can declare a variable or an object without specifying its type by using auto. For example: auto i 阅读全文
posted @ 2020-11-19 11:29 Codroc 阅读(76) 评论(0) 推荐(0) 编辑
摘要: Type Alias (similar to typedef) // typedef void (*func)(int, int) using func = void (*) (int, int); // the name 'func' now denotes a pointer to functi 阅读全文
posted @ 2020-11-18 21:08 Codroc 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Variadic Template 谈的是 template function template class template 变化的是 template parameters 参数个数 (variadic number) 利用参数个数逐一递减的特性,实现递归函数调用,使用 function tem 阅读全文
posted @ 2020-11-18 21:05 Codroc 阅读(146) 评论(0) 推荐(0) 编辑
摘要: =default, =delete 如果你自行定义一个 ctor,那么编译器就不会再给你一个 default ctor(包括了构造函数,拷贝构造函数,拷贝赋值函数)。 如果你强制加上了 =default,就可以重新获得并使用 default ctor。 Big Three 就是所谓的: 构造函数 拷 阅读全文
posted @ 2020-11-18 10:27 Codroc 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 译者记 为什么函数模版的全特化是不参与函数重载的呢?而为什么函数模版没有偏特化概念呢?其实是C++语法规定的,但是在平时的工作过程中,出现过因为函数版本不能偏特化困扰我们的工作吗?答案是没有,也许很多人忽略了这个问题,主要是因为可以通过函数重载来规避这个问题(或者可以认为这不是一个问题)。 另,在《 阅读全文
posted @ 2020-11-05 16:06 Codroc 阅读(663) 评论(0) 推荐(0) 编辑
摘要: boost::noncopyable 的作用 boost::noncopyable 是用于针对 C++ 编译器的。具体看下面的代码: #include <iostream> using namespace std; class car{ public: car(int price) : _price 阅读全文
posted @ 2020-08-29 16:54 Codroc 阅读(500) 评论(0) 推荐(0) 编辑
摘要: 记录 C++ Primer 中的一些关键概念 关键概念:名字查找与继承 理解函数调用的解析过程对于理解 C++ 的继承至关重要,假定我们调用 p->mem() 或 obj.mem() 则执行以下 4 个步骤: 首先确定 p(或 obj )的静态类型。因为我们调用的是一个成员,所以该类型一定是个类类型 阅读全文
posted @ 2020-08-25 10:27 Codroc 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 面子是一个人最放不下的,又是最没用的东西,当你越是在意它,它就会越发沉重,越发让你寸步难行。————亦舒 阅读全文
posted @ 2020-08-24 09:14 Codroc 阅读(141) 评论(0) 推荐(0) 编辑