C++0x新特性

   1、auto keyword 自动变量类型推断
   auto iNum = 0;
   iNum推断为int型
   2、decltype声明变量类型
   int nVariable1;
   decltype(nViarable1)<==>int
auto xVariable = ReturnXFun();
想再获得ReturnXFun的返回值类型,但不想再调用它
decltype(nVariable) nNewVariable;
   3、nullptr空指针,一个关键字
       NULL其实是0,nullptr真空
   4、static_assert静态断言
       static_assert声明有助于在编译时测试软件中的断言
       static_assert(expression,message)
       static_assert(10==9, "Nine is not equal to ten")
       编译时错误:error C2338:Nine is not equal to ten
       判断程序是否在32位编译器下运行
       static_assert(sizeof(void *) == 4, "This code should only be complied as 32-bit")
    5、Lambda(匿名)表达式
        最基本的lambda:
        []{};
        []是匿名表达式的引入符号,告诉编译器下面的表达式是匿名的。{}匿名表达式的定义部分
        double pi = []{return 3.14159}();//简写
        double pi = [](){return 3.14159}();//简写
        double pi = [](void) {return 3.14159}();//参数为空
        后加括号表示调用
        int nMax = [](int n1, int n2){
             return ((n1>n2)?n1:n2)
        }(56,11);
上一篇:为 IIS FTP 指定被动模式所使用的端口范围


下一篇:直击 KubeCon| KubeCon 第三日亮点全解读(含 PPT下载)