[C++]C++11新特性
2013-10-19 16:18
351 查看
0. C++11 compiler support shootout
http://cpprocks.com/c11-compiler-support-shootout-visual-studio-gcc-clang-intel/ http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx1. Important Minor Syntax Cleanups
//Spaces in Template Expressions std::vector<std::list<int>>; //nullptr and std::nullptr_t f(0); //calls f(int) f(NULL); //calls f(int) if NULL is 0,ambiguous otherwise f(nullptr); //calls f(void*)
2. Automatic Type Deduction with auto
auto i = 42; // i has type int // std::vector<std::string> v; auto pos = v.begin(); // std::vector<std::string>::iterator // auto func = [](int x)->bool { //.... }; // the type of lambda taking an int and returnin a bool
3. Uniform Initialization and Initializer Lists
/* not support in vs2012 */ int values[] { 1, 2,3 }; std::vector<int> v {2, 3, 5, 7,11, 13, 17}; std::vector<std::string> cities { "Berlin", "New York", "London", "Braunschweig", "Cairo", "Cologne" }; //std::initializer_list<> class P { public: P(int,int); P(std::initializer_list<int>); }; // P p(77,5); //calls P::P(int,int) P q{77,5}; //calls P::P(initializer_list) P r{77,5,42}; //calls P::P(initializer_list) P s={77,5}; //calls P::P(initializer_list)
4. Range-Based for Loops
/* for ( decl :coll ){ statement } */ std::vector<int> v; for(auto& item : v) { //.... }
相关文章推荐
- C++:C++11新特性详解(1)
- 【陷阱代码】c++ 第二篇 c++11新特性及偏冷门语法场景 面对审查代码
- 【C/C++】C++11新特性:std::bind
- C++模板库(包含C++11特性)
- 每个C++开发者都应该使用的十个C++11特性
- c++基础——c++11中的新特性
- C++开发者都应该使用的10个C++11特性(转)
- C++开发者都应该使用的10个C++11特性
- C++11标准在2011年8月份获得一致通过,这是自1998年后C++语言第一次大修订,对C++语言进行了改进和扩充。随后各编译器厂商都各自实现或部分实现了C++中的特性。 如需查看各编译器对C++
- C++ 11学习和掌握 ——《深入理解C++ 11:C++11新特性解析和应用》读书笔记(一)
- C++开发者都应该使用的10个C++11特性
- [C++] C++11给我们带来的新特性
- 如何用eclipse开发有c++11新特性的C++程序
- 每个C++开发者都应该使用的十个C++11特性
- C++Primer第五版中的c++11特性归纳(二)
- [c++]Dev-c++使用C++11新特性
- 【C++】C++11特性:模板推导和循环区间
- 【C/C++】C++11新特性:=default 和 =delete
- 每个C++开发者都应该使用的十个C++11特性
- c++学习笔记(部分语法及c++11新特性)