Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Nov 19, 2022
1 parent 98349bd commit 7c99be8
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 0 deletions.
3 changes: 3 additions & 0 deletions 16/00/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}")

project(CppCMakeDemo LANGUAGES CXX)

include(MyUsefulFuncs)

add_subdirectory(pybmain)
add_subdirectory(biology)
Binary file modified 16/slides.pptx
Binary file not shown.
16 changes: 16 additions & 0 deletions 17/00.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
map<string, int> items = {
{"hello", 1},
{"world", 2},
};

items["time"] = 4;
int time = items.at("time");
cout << time << endl;
}
8 changes: 8 additions & 0 deletions 17/00.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
items = dict([
("hello", 1),
("world", 2),
])

items["time"] = 4
time = items["time"]
print(time)
15 changes: 15 additions & 0 deletions 17/00a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
map<string, int> items = {
{"hello", 1},
{"world", 2},
};

int time = items["hello"];
cout << time << endl;
}
15 changes: 15 additions & 0 deletions 17/00b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
map<string, int> items = {
{"hello", 1},
{"world", 2},
};

int time = items["hell"];
cout << time << endl;
}
13 changes: 13 additions & 0 deletions 17/01.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
#include <map>
#include "printer.h"

using namespace std;

int main() {
map<string, int> m;
m["hello"] = 1;
m["world"] = 2;
cout << m << endl;
return 0;
}
13 changes: 13 additions & 0 deletions 17/02.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
#include <map>
#include "printer.h"

using namespace std;

int main() {
map<string, int> m;
m.at("hello") = 1;
m.at("world") = 2;
cout << m << endl;
return 0;
}
39 changes: 39 additions & 0 deletions 17/printer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include <iostream>
#include <utility>
#include <type_traits>

namespace std {

template <class T, class = const char *>
struct __printer_test_c_str {
using type = void;
};

template <class T>
struct __printer_test_c_str<T, decltype(std::declval<T>().c_str())> {};

template <class T, int = 0, int = 0, int = 0,
class = decltype(std::declval<std::ostream &>() << *++std::declval<T>().begin()),
class = decltype(std::declval<T>().begin() != std::declval<T>().end()),
class = typename __printer_test_c_str<T>::type>
std::ostream &operator<<(std::ostream &os, T const &v) {
os << '{';
auto it = v.begin();
if (it != v.end()) {
os << *it;
for (++it; it != v.end(); ++it)
os << ',' << *it;
}
os << '}';
return os;
}

template <class T1, class T2>
std::ostream &operator<<(std::ostream &os, std::pair<T1, T2> const &v) {
os << '{' << v.first << ',' << v.second << '}';
return os;
}

}
Binary file added 17/slides.pptx
Binary file not shown.
2 changes: 2 additions & 0 deletions 17/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target("exec")
add_files("01.cpp")

0 comments on commit 7c99be8

Please sign in to comment.