implement read() and print() functions for easier I/O
This commit is contained in:
parent
a994e7d10d
commit
11b6ae9729
7 changed files with 67 additions and 38 deletions
35
example.cpp
35
example.cpp
|
|
@ -1,4 +1,4 @@
|
|||
// -*- compile-command: "g++ -Iinclude -D_GLIBCXX_DEBUG -fsanitize=address,undefined -g3 -ggdb3 -std=c++17 example.cpp -o example && SOI_COLOR=1 SOI_EOFCHECK=1 ./example <<< ''" -*-
|
||||
// -*- compile-command: "g++ -Iinclude -D_GLIBCXX_DEBUG -fsanitize=address,undefined -g3 -ggdb3 -std=c++17 example.cpp -o example && SOI_COLOR=1 SOI_EOFCHECK=1 ./example <<< '4 5 blub 3 1 4'" -*-
|
||||
#include <soi>
|
||||
|
||||
inline std::string methodName(const std::string& prettyFunction) {
|
||||
|
|
@ -9,26 +9,35 @@ inline std::string methodName(const std::string& prettyFunction) {
|
|||
}
|
||||
|
||||
struct A{
|
||||
void operator()() const {
|
||||
void operator()() const {
|
||||
dbg(methodName(__PRETTY_FUNCTION__));
|
||||
dbg("here");
|
||||
}
|
||||
dbg("here");
|
||||
}
|
||||
void bar(int a, int b, string c) const {
|
||||
dbg("imbar");
|
||||
}
|
||||
void foo(int a=3, int b=5, string c="hi") const {
|
||||
dbg(methodName(__PRETTY_FUNCTION__));
|
||||
dbg("bar");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
signed main() {
|
||||
dbg(methodName(__PRETTY_FUNCTION__));
|
||||
A a;
|
||||
a();
|
||||
a.foo();
|
||||
a.bar(3,4,"hi");
|
||||
|
||||
int i = read_int();
|
||||
int j = read_int();
|
||||
print(i, j);
|
||||
|
||||
print("read string",read<string>());
|
||||
print('h','e','l','l','o');
|
||||
print("false",'=',false);
|
||||
print("true",'=',true);
|
||||
|
||||
print(read_vector<int>(3));
|
||||
|
||||
int l=3, r=5;
|
||||
dbg(tuple{l, r});
|
||||
dbg();
|
||||
|
|
@ -48,4 +57,16 @@ signed main() {
|
|||
dbg(map<int, string>{{3,"three"},{1,"one"}});
|
||||
dbg(tuple{unordered_map<int, string>{{3,"three"},{1,"one"}}});
|
||||
dbg(unordered_set<int>{3,1,4});
|
||||
|
||||
print("v-- empty line");
|
||||
print();
|
||||
print("^-- empty line");
|
||||
print("tuple",make_tuple(3, 1, 4, 1));
|
||||
print(vector<int>{3,1,4,1,5,9,2,6});
|
||||
print(vector<pair<int, int>>{{3,1},{4,1}});
|
||||
print(vector<pair<int, vector<string>>>{{3,{"hi"}},{4,{"hello", "world"}}});
|
||||
print(set<int>{3,1,4});
|
||||
print(map<int, string>{{3,"three"},{1,"one"}});
|
||||
print(tuple{unordered_map<int, string>{{3,"three"},{1,"one"}}});
|
||||
print(unordered_set<int>{3,1,4});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue