see #12: translate ch09

This commit is contained in:
Changkun Ou
2019-07-14 23:10:07 +02:00
parent 3fc59f9bea
commit 9779283735
6 changed files with 189 additions and 24 deletions

View File

@@ -1,7 +0,0 @@
#include <list>
#include <algorithm>
int main() {
std::list<int> l = {1, 2, 3};
std::sort(l.begin(), l.end());
return 0;
}

View File

@@ -33,18 +33,18 @@ int main()
try {
may_throw();
} catch (...) {
std::cout << "捕获异常, 来自 my_throw()" << std::endl;
std::cout << "exception captured from my_throw()" << std::endl;
}
try {
non_block_throw();
} catch (...) {
std::cout << "捕获异常, 来自 non_block_throw()" << std::endl;
std::cout << "exception captured from non_block_throw()" << std::endl;
}
try {
block_throw();
} catch (...) {
std::cout << "捕获异常, 来自 block_throw()" << std::endl;
std::cout << "exception captured from block_throw()" << std::endl;
}
}

View File

@@ -4,7 +4,7 @@
//
// created by changkun at changkun.de
//
// 字面量
// literals
#include <iostream>
#include <string>
@@ -18,16 +18,16 @@ std::string operator""_wow2 (unsigned long long i) {
}
int main() {
std::string str = R"(C:\\What\\The\\Fxxk)";
std::string str = R"(C:\\File\\To\\Path)";
std::cout << str << std::endl;
int value = 0b1001010101010;
std::cout << value << std::endl;
auto str = "abc"_wow1;
auto str2 = "abc"_wow1;
auto num = 1_wow2;
std::cout << str << std::endl;
std::cout << str2 << std::endl;
std::cout << num << std::endl;
return 0;
}

7
code/9/Makefile Normal file
View File

@@ -0,0 +1,7 @@
all: $(patsubst %.cpp, %.out, $(wildcard *.cpp))
%.out: %.cpp Makefile
clang++ $< -o $@ -std=c++2a -pedantic
clean:
rm *.out