
C++11
lvxiangyu11
我是一只菜鸡
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++11-14 第11讲 decltype
decltype从表达式的类型推断出要定义的变量类型 map<string, float> cell; decltype(cell)::value_type elem;//推断容器获得类型 //1.用来声明返回参数 //template<typename T1,typename T2> //decltype(x + y) add(T1 x, T2 y);//错误因...原创 2018-10-11 11:10:41 · 879 阅读 · 0 评论 -
C++11-14 第9讲 Alias Template(化名)
template<typename T> using Vec = std::vector<T, MyAlloc<T>>;//给一个化名 Vec<int> coll; //typedef 做不到,typedef不能接受参数 //define 也不行 //#define Vec<T> template<typename T> ...原创 2018-10-10 09:31:48 · 545 阅读 · 0 评论 -
C++11-14 第8讲 =default =delete
default constructor(默认构造函数)空函数 如果自己定义了一个构造函数,编译器就不会再提供一个默认构造函数。 如果强制加一个=default,会继续给一个默认构造函数。 参数相同,再要求提供构造函数会报错。 class P { public: P(int i1,int i2):d1(i1),d2(i2){} P(const P& tmp):d1(tmp.d1...原创 2018-10-10 09:05:06 · 150 阅读 · 0 评论 -
C++11-14 第7讲 Range-based for loop(范围循环)
非常简单的一个点 #include<iostream> #include<initializer_list> #include<vector> using namespace std; int main() { for (int i : {1, 2, 3, 4, 5, 6}) { cout << i << endl; ...原创 2018-10-09 16:59:19 · 1191 阅读 · 0 评论 -
C++11-14 第6讲 explicit关键字
explicit 用来针对构造函数有多个实参。 #include<iostream> #include<initializer_list> #include<array> using namespace std; struct Complex {//c++1.0版本 int real, imag; explicit Complex(int re...原创 2018-10-09 15:36:19 · 241 阅读 · 0 评论 -
C++11-14 第4讲 auto
auto 用作自动推导类型 用在 1.for中做自动变量推导 2.迭代器太长 3.泛化函数返回值或参数 4.lambda函数原创 2018-10-08 21:38:03 · 261 阅读 · 0 评论 -
C++11-14 第5讲 Uniform Initialization 一致初始化值 &initializer_list
版权说明:本博文属于个人笔记,本人保留对本文的所有权益,未经许可不得以任何形式转载。 Uniform Initialization 一致初始化值 新手困惑初始化怎么写。可能发生在(){}=中 任何初始化都用共通写法:{} 旧:Rect r1={1,2,3};Rect r1(1,2,3);int ia[6]={1,2,3};//好多种 现在:全用{}。编译器看到{t1,t2...tn}做...原创 2018-10-08 21:35:40 · 308 阅读 · 0 评论 -
C++11-14 第3讲 nullptr(空指针),std::nullptr_t
版权说明:本博文属于个人笔记,本人保留对本文的所有权益,未经许可不得以任何形式转载 nullptr(空指针),std::nullptr_t C++11允许使用 nullptr取代0或NULL, std::nullptr_t(是c++空指针类型的文字)定义:typedef decltype(nullptr) nullptr_t;//在<stddef>中 //decltype,在C...原创 2018-10-08 21:32:23 · 2964 阅读 · 0 评论 -
C++11-14 第2讲 Space in Template Expressions(模板表达式中的空格)
版权说明:本博文属于个人笔记,本人保留对本文的所有权益,未经许可不得以任何形式转载。 vector<list<int> >;//过去要空格 vecotr<list<int>>;//从C++11可以去掉空格 (这居然是一个点。。。。) ...原创 2018-10-08 11:28:43 · 259 阅读 · 0 评论 -
C++11-14 第1讲 Variadic Template(可变参数函数模板)
...从C就存在了 版权说明:本博文属于个人笔记,本人保留对本文的所有权益,未经许可不得以任何形式转载。 代码略去,可参考:https://blog.csdn.net/Cherish_2014/article/details/49256801 1.递归分解可变参数函数的参数包 #include<iostream> #include<bitset> using na...原创 2018-10-07 22:56:21 · 922 阅读 · 0 评论 -
C++11-14新特性 第0讲
说明:本博客系列为课程笔记,课程是:C++2.0新特性 侯捷教授 源自Boolan 两个部分:语言部分+标准库部分 基础:c++语法语意 目标:较全面认识c++2.0新特性,从实例获得验证 c++历史: c++ 98(0.1) c++ 03(TR1,technical report 1) c++11(2.0) c++14 c++17 同文件的使用不带.h,C...原创 2018-10-07 21:02:21 · 308 阅读 · 0 评论 -
C++11-14 第12讲 lambda
#include <iostream> #include<set> #include<vector> //lambda改变了对c++标准库的使用 // using namespace std; int main() { [] { std::cout << "This is a simple lambda function.\n"; }()...原创 2018-10-13 00:45:10 · 151 阅读 · 0 评论 -
C++11-14 第10讲 template template parameter(模板模板参数)
template<typename T, template <typename T> class Container > class XCls{ private: Container<T> c; public: }; https://blog.csdn....原创 2018-10-10 09:39:50 · 1057 阅读 · 0 评论