今年12月份, Stroustroup和Hurt两位大神, 搞了个Cpp Guiderlines, 可以参考:
总体来讲就是宣传C++11, C++14, 及未来的C++17, modern C++ programming,
从Stroustroup的PPT来看, 主要阐述了:
1. 不要使用raw pointer, 即不直接使用new、delete.
2. 使用shared_ptr需注意性能, 不要滥用, 尽量使用unique_ptr,即move属性.
3. move (transfer)特性提高性能.
4. new features for modern c++.
5. no compromise for performance.
To reflect the lvalue/rvalue and const/non-const distinctions, there are three kinds of references:
-
lvalue references(&): to refer to objects whose value we want to change
-
const references(const&): to refer to objects whose value we do not want to change (e.g., a constant)
-
rvalue references(&&): to refer to objects whose value we do not need to preserve after we have
used it (e.g., a temporary)
Collectively, they are called references. The first two are both called lvalue references.
Both a const lvalue reference and an rvalue reference can bind to an rvalue. However, the purposes will be
fundamentally different:
-
We use rvalue references to implement a "destructive read" for optimization of what would otherwise have required a copy.
-
We use a const lvalue reference to prevent modification of an argument.
阅读(1200) | 评论(0) | 转发(0) |