C++11、C++14、C++17增加的新关键字和新语法特性
#include <iostream>
#include <map>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
int main(int argc, char **argv) {
double b = double{1.2};
int arr1[3]{1, 2, 3};
vector<int> iv{1, 2, 3};
map<int, string> key_value{{1, "a"}, {2, "b"}};
string str{"Hello World"};
int *a = new int{3};
int *arr2 = new int[]{1, 2, 3};
for (vector<int>::const_iterator itr = iv.cbegin(); itr != iv.cend(); itr++)
cout << *itr << " ";
cout << endl;
for (auto itr = iv.cbegin(); itr != iv.cend(); itr++)
cout << *itr << " ";
cout << endl;
for (int i = 0; i < iv.size(); i++)
cout << iv[i] << " ";
cout << endl;
for (int i : iv)
cout << i << " ";
cout << endl;
for (auto p : key_value)
cout << p.first << " " << p.second << endl;
vector<int> vec1{1, 6, 2, 5, 3, 9, 7};
for (int i : vec1)
cout << i << " ";
cout << endl;
sort(vec1.begin(), vec1.end(),
[](int param1, int param2) -> bool { return param1 < param2; });
for (int i : vec1)
cout << i << " ";
cout << endl;
auto tup1 = std::make_tuple("Hello World!", 'a', 3.14, 0);
auto tup2 = std::make_tuple(3.14, 1, 'a');
double dt; int it; char c;
std::tie(dt, it, c) = tup2;
std::tuple<float, string> tup3(3.14, "pi");
std::tuple<int, char> tup4(10, 'a');
auto tup5 = tuple_cat(tup3, tup4);
return 0;
}