Skip to content

Commit 7c99be8

Browse files
committed
1
1 parent 98349bd commit 7c99be8

11 files changed

+124
-0
lines changed

16/00/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ endif()
66
set(CMAKE_CXX_STANDARD 20)
77
set(CMAKE_CXX_STANDARD_REQUIRED ON)
88
set(CMAKE_CXX_EXTENSIONS OFF)
9+
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}")
910

1011
project(CppCMakeDemo LANGUAGES CXX)
1112

13+
include(MyUsefulFuncs)
14+
1215
add_subdirectory(pybmain)
1316
add_subdirectory(biology)

16/slides.pptx

4.87 MB
Binary file not shown.

17/00.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <map>
4+
5+
using namespace std;
6+
7+
int main() {
8+
map<string, int> items = {
9+
{"hello", 1},
10+
{"world", 2},
11+
};
12+
13+
items["time"] = 4;
14+
int time = items.at("time");
15+
cout << time << endl;
16+
}

17/00.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
items = dict([
2+
("hello", 1),
3+
("world", 2),
4+
])
5+
6+
items["time"] = 4
7+
time = items["time"]
8+
print(time)

17/00a.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <map>
4+
5+
using namespace std;
6+
7+
int main() {
8+
map<string, int> items = {
9+
{"hello", 1},
10+
{"world", 2},
11+
};
12+
13+
int time = items["hello"];
14+
cout << time << endl;
15+
}

17/00b.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <map>
4+
5+
using namespace std;
6+
7+
int main() {
8+
map<string, int> items = {
9+
{"hello", 1},
10+
{"world", 2},
11+
};
12+
13+
int time = items["hell"];
14+
cout << time << endl;
15+
}

17/01.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
#include <map>
3+
#include "printer.h"
4+
5+
using namespace std;
6+
7+
int main() {
8+
map<string, int> m;
9+
m["hello"] = 1;
10+
m["world"] = 2;
11+
cout << m << endl;
12+
return 0;
13+
}

17/02.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
#include <map>
3+
#include "printer.h"
4+
5+
using namespace std;
6+
7+
int main() {
8+
map<string, int> m;
9+
m.at("hello") = 1;
10+
m.at("world") = 2;
11+
cout << m << endl;
12+
return 0;
13+
}

17/printer.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#pragma once
2+
3+
#include <iostream>
4+
#include <utility>
5+
#include <type_traits>
6+
7+
namespace std {
8+
9+
template <class T, class = const char *>
10+
struct __printer_test_c_str {
11+
using type = void;
12+
};
13+
14+
template <class T>
15+
struct __printer_test_c_str<T, decltype(std::declval<T>().c_str())> {};
16+
17+
template <class T, int = 0, int = 0, int = 0,
18+
class = decltype(std::declval<std::ostream &>() << *++std::declval<T>().begin()),
19+
class = decltype(std::declval<T>().begin() != std::declval<T>().end()),
20+
class = typename __printer_test_c_str<T>::type>
21+
std::ostream &operator<<(std::ostream &os, T const &v) {
22+
os << '{';
23+
auto it = v.begin();
24+
if (it != v.end()) {
25+
os << *it;
26+
for (++it; it != v.end(); ++it)
27+
os << ',' << *it;
28+
}
29+
os << '}';
30+
return os;
31+
}
32+
33+
template <class T1, class T2>
34+
std::ostream &operator<<(std::ostream &os, std::pair<T1, T2> const &v) {
35+
os << '{' << v.first << ',' << v.second << '}';
36+
return os;
37+
}
38+
39+
}

17/slides.pptx

1.76 MB
Binary file not shown.

17/xmake.lua

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target("exec")
2+
add_files("01.cpp")

0 commit comments

Comments
 (0)