Skip to content

Commit

Permalink
add14
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed May 26, 2022
1 parent 932b071 commit 2281dcf
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
Binary file modified 13/slides.pptx
Binary file not shown.
1 change: 1 addition & 0 deletions 14/.vim_localrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nmap <silent> <F5> <F7>
13 changes: 13 additions & 0 deletions 14/01.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <vector>
#include <set>
#include "printer.h"

using namespace std;

int main() {
vector<int> a = {9, 8, 5, 2, 1, 1};
cout << "vector=" << a << endl;
set<int> b = {9, 8, 5, 2, 1, 1};
cout << "set=" << b << endl;
return 0;
}
17 changes: 17 additions & 0 deletions 14/02.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <vector>
#include <set>
#include "printer.h"

using namespace std;

int main() {
vector<int> a = {1, 2, 3, 4, 5, 6, 7};
vector<int>::iterator a_it = a.begin();
cout << "vector[0]=" << *a_it << endl;

set<int> b = {1, 2, 3, 4, 5, 6, 7};
set<int>::iterator b_it = b.begin();
cout << "set[0]=" << *b_it << endl;

return 0;
}
26 changes: 26 additions & 0 deletions 14/printer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <iostream>
#include <utility>

namespace std {

template <class T,
class = decltype(std::declval<ostream &>() <<
*++std::declval<T>().begin()),
class = decltype(std::declval<T>().begin() !=
std::declval<T>().end())>
ostream &operator<<(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;
}

}
Binary file modified 14/slides.pptx
Binary file not shown.

0 comments on commit 2281dcf

Please sign in to comment.