C++11简摘

C++11特性:
一、右值引用,move
二、泛化的常数表示,constexpr
三、外部模板,extern
四、初始化列表,std::initializer_list<>
五、统一的初始化,{}
六、类型推导,auto,decltype
七、范围for循环,for(auto x: list)
八、lambda表达式,[=,&,x,&x](){}
九、返回值推导函数语法,template<typename LHS, typename RHS>
                        auto AddingFunc(const LHS& lhs, const RHS& rhs) -> decltype(lhs+rhs) { return lhs + rhs; }
十、构造函数复用(委托|转接),SomeType(int i, string& s):num(i), name(s) {}
                             SomeType():SomeType(0, "invalid"){}
                             SomeType(int i): SomeType(i, "guest"){}
十一、虚函数重载限定符号,override(派生),final(禁止派生)
十二、空指针,nullptr
1三、强类型枚举,enum EM1:unsigned int {},enum class EM2:unsigned int {}
1四、角括号,std::vector<SomeType<(1>2)>>,不解析为右移
1五、显式转换限定,explicit 
1六、模板别名,using,template<typename second>
                     using TypedefName = SomeType<OtherType, second, 5>
                     using PFD = void(*)(double)
1七、变长参数模板,template<typename ... Args>
                  void print(const char* s, T value, Args... args);
1八、编译器支持unicode,char16_t,char32_t,u8|u|U|R
1九、thread_local
20、是用或禁用默认函数,SomeType() = default; SomeType(const SomeType&) = delete;
2一、static_assert
2二、sizeof支持对象成员
2三、线程支持:std::thread,std::mutex,std::recursive_mutex,std::condition_variable,std::condition_variable_any,std::lock_guard,std::unique_lock                                  http://www.cnblogs.com/haippy/p/3284540.html
2四、元组,tuple
2五、散列表,unordered_set|unordered_multiset|unordered_map|unordered_multimap
2六、正则表达式,regex
2七、通用智能指针,shared_ptr
2八、扩展随机数:
        随机数算法:linear_congruential|subtract_with_carry|mersenne_twister
        标准分布:uniform_int_distribution(离散型均匀分布) bernoulli_distribution(伯努利分布) geometric_distribution(几何分布) poisson_distribution(卜瓦松分布)
                  binomial_distribution(二项分布) uniform_real_distribution(离散型均匀分布) exponential_distribution(指数分布) normal_distribution(正态分布)
                  gamma_distribution(伽玛分布)
        示例:    std::uniform_int_distribution<int> distribution(0, 99);
                std::mt19937 engine;
                auto generator = std::bind(distribution, engine);
                int random = generator();
2九、包装引用,std::ref
30、多态函数对象包装器:std::function std::plus  std::ref(car) Test car;
3一、std::unique_ptr std::auto_ptr std::shared_ptrhtml

相关文章
相关标签/搜索