zoukankan      html  css  js  c++  java
  • [C++]C++11新特性

    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.aspx

    1. 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) {
        //....
    }

  • 相关阅读:
    .globl分析
    ARM汇编指令
    汇编文件后缀.s与.S
    Uboot命令
    BIOS、BootLoader、uboot对比
    汇编的WEAK关键字
    USB OTG
    前端学习笔记——CSS选择器
    前端学习笔记——HTML
    【1】python模块:自定义模块的3种导入方式
  • 原文地址:https://www.cnblogs.com/lambdatea/p/3377986.html
Copyright © 2011-2022 走看看