C++11 new feature

  1. C++11 在类中引入了Move Constructor and the Move Assignmnt Operaetor,所谓‘move’指的是在复制对象时,left object 不用再建立资源,直接把right object 的资源当作本身的来用。而right object 的资源将所有被设置为default ,即为empty object 。
    1. http://blog.smartbear.com/c-plus-plus/c11-tutorial-introducing-the-move-constructor-and-the-move-assignment-operator/
  2. 引入了关键字auto 和 decltype ,有了auto能够在定义变量时不用指出变量的类型,编译器本身推断出变量的类型。auto 的最大用我本身感受有两点: (1)有些太长的类型好比STL的一些迭代器的类型定义时能够省去左边的长串字符的书写,由编译器本身去推断类型;(2)当auto 和template结合在一块儿时能够写出更加灵活的代码,此时可能须要借助decltype来推测输出的类型。
    1. http://blog.smartbear.com/c-plus-plus/c11-tutorial-let-your-compiler-detect-the-types-of-your-objects-automatically/
    2. http://blog.csdn.net/fire_lord/article/details/8499596
  3. 类的继承控制关键字:override 和 final .在类的继承中有时须要在derived的class中对虚函数进行重写,但这个地方很容易出现错误是的derived class 中“重写”的函数和based class的函数签名不一致,使得本来打算进行的重写变成了定义新的函数。若是加了override关键字,编译器会自动检查函数签名是否和based class的函数签名是否一致。而final关键字则使得类和类中一些函数不能再继承。要注意下这两个关键字不是reserved keyword 而是 CSK(context sensitive keywords),即只有在适当的contex下才会被当作keyword .
    1. http://blog.smartbear.com/c-plus-plus/use-c11-inheritance-control-keywords-to-prevent-inconsistencies-in-class-hierarchies/
    2. http://blog.csdn.net/fire_lord/article/details/8540592
  4. Lambda Expressions (匿名函数)。语法结构:[capture clause](parameters)->return-type{body} 。有人说引入这主要缘由是function programering 的流行,可能我本身对于函数式编程不是很了解,因此没法领会它的强大。lambda Expessions有三个优点:1)提供了比function class 更加convinent 的工具,由于其不用定义构造函数以及member,2)编译器对其做出的优化比通常的函数更大;3)其比通常的函数有更大的security,由于lambda expession 是local的。 
    1. http://blog.smartbear.com/c-plus-plus/c11-tutorial-lambda-expressions-the-nuts-and-bolts-of-functional-programming/
    2. http://ciere.com/cppnow12/lambda.pdf
    3. http://blog.csdn.net/srzhz/article/details/7934652
  5. 强类型的enum,主要解决enum 的命名冲突问题。定义时须要在enum后面加上class 关键字。不过强类型的enum不支持和int 的转换,刚习惯的enum在类中定义数组的长度以及索引,看来仍是要使用old enum style 来进行。
    1. http://blog.smartbear.com/c-plus-plus/closer-to-perfection-get-to-know-c11-scoped-and-based-enum-types/
  6. right reference 
    1. http://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers
  7. constexpr 
    1. http://blog.smartbear.com/c-plus-plus/using-constexpr-to-improve-security-performance-and-encapsulation-in-c/

 

 

 

http://msdn.microsoft.com/en-us/library/vstudio/hh279654.aspxhtml

http://www.cnblogs.com/hujian/archive/2012/12/08/2809298.htmlexpress

http://www.codeproject.com/Articles/570638/Ten-Cplusplus11-Features-Every-Cplusplus-Developer编程

http://blog.smartbear.com/c-plus-plus/the-biggest-changes-in-c11-and-why-you-should-care/数组

http://blog.csdn.net/fire_lord/article/category/1324600ide

相关文章
相关标签/搜索