mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 04:34:40 +03:00
see #12: translate ch09
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
7
code/9/Makefile
Normal file
@@ -0,0 +1,7 @@
|
||||
all: $(patsubst %.cpp, %.out, $(wildcard *.cpp))
|
||||
|
||||
%.out: %.cpp Makefile
|
||||
clang++ $< -o $@ -std=c++2a -pedantic
|
||||
|
||||
clean:
|
||||
rm *.out
|
||||
Reference in New Issue
Block a user