-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstring_iterator_test.cpp
51 lines (41 loc) · 1.27 KB
/
string_iterator_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <unistd.h>
#include <functional>
#include <string>
#include <iostream>
using namespace std;
#define PRINT_IMPL(ok, a) do { \
if (ok) { \
cout << "ok..., " << a << endl; \
} else { \
cout << "a: " << a << endl; \
} \
} while (0)
template<bool is_ok, typename T>
void print(T a) {
PRINT_IMPL(is_ok, a);
}
int main() {
string s("12345");
const char *i = s.begin().base();
cout << "i: " << *i << endl;
string ss;
cout << "back: " << (int64_t)ss.end().base() << ", length: " << (int64_t)&ss[0] + ss.length() << std::endl;
print<true>(s);
print<false>(1);
bool a = false;
if (a = true) {
print<true>(a);
}
int ret;
// ret = access("/Users/tangjintao", F_OK);
// cout << "ret: " << ret << endl;
// ret = symlink("/Users/tangjintao/Data/tf_docs", "/Users/tangjintao/tf_docs");
// cout << "ret: " << ret << endl;
// ret = access("/Users/tangjintao/tf_docs", F_OK);
// cout << "ret: " << ret << endl;
// ret = remove("/Users/tangjintao/tf_docs");
cout << "ret: " << ret << endl;
auto f = std::bind(&print<true, int>, std::placeholders::_1);
f(120);
return 0;
}