Chinaunix首页 | 论坛 | 博客
  • 博客访问: 73519
  • 博文数量: 25
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 220
  • 用 户 组: 普通用户
  • 注册时间: 2015-02-07 20:35
个人简介

Linux software developer, open source player (maybe).

文章分类

全部博文(25)

文章存档

2016年(1)

2015年(24)

我的朋友

分类: C/C++

2015-12-27 11:19:37

今年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.



阅读(1140) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~