先看一个简单的例子对比
//old
std::list<int> l;
std::list<int>::iterator it = l.begin();
//new
std::list<int> l;
auto it = l.begin();
很酷吧?auto原来是生命自动变量(局部变量)的关键词,在c++0x中有了新的含义
c++0x是新一代的c++标准,引入了许多值得期待的特性。目前gcc4.4以上版本和vs2010实现了其大多数特性。
可以从下面链接的FAQ中对c++0x的新特性做一个简单的了解。
http://www2.research.att.com/~bs/C++0xFAQ.html
- The new libraries without features that depends on new language facilities (e.g. variadic templates and constexpr )
- Simple and simple to implement features that help users in small but noticeable ways:
- auto
- enum class
- long long
- nullptr
- right brackets
- static_assert
- language features that help implement the C++0x standard libraries (enabling an upgrade/improvement of the standard libraries):
- constexpr
- initializer lists
- general and uniform initialization (incl. the prevention of narrowing )
- rvalue references
- variadic templates
- a version of the standard library with all of these features used
- Features related to concurrency:
- memory model
- thread_local
- atomic types
- local types as template arguments
- lambdas
- a version of the standard library with complete concurrency support
- PODs (generalized)
从下面的链接中可以获得gcc对c++0x的支持的相关信息
http://gcc.gnu.org/projects/cxx0x.html
从下面的wiki链接,可以得到更全面的信息,和一些简单的代码例子
http://en.wikipedia.org/wiki/C%2B%2B0x