Skip to content
This repository was archived by the owner on Jun 12, 2018. It is now read-only.

Commit 704af7b

Browse files
committed
Simplified examples.cpp slightly: removed all occurences of std::
1 parent 75a86af commit 704af7b

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

examples.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,83 +10,83 @@ int main() {
1010

1111
cout << "Example 1 - the mandatory Hello World" << endl;
1212
Process process1("echo Hello World", "", [](const char *bytes, size_t n) {
13-
cout << "Output from stdout: " << std::string(bytes, n);
13+
cout << "Output from stdout: " << string(bytes, n);
1414
});
1515
auto exit_status=process1.get_exit_status();
1616
cout << "Example 1 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
17-
std::this_thread::sleep_for(std::chrono::seconds(5));
17+
this_thread::sleep_for(chrono::seconds(5));
1818

1919

2020
cout << endl << "Example 2 - cd into a nonexistent directory" << endl;
2121
Process process2("cd a_nonexistent_directory", "", [](const char *bytes, size_t n) {
22-
cout << "Output from stdout: " << std::string(bytes, n);
22+
cout << "Output from stdout: " << string(bytes, n);
2323
}, [](const char *bytes, size_t n) {
24-
cout << "Output from stderr: " << std::string(bytes, n);
24+
cout << "Output from stderr: " << string(bytes, n);
2525
//add a newline for prettier output on some platforms:
2626
if(bytes[n-1]!='\n')
2727
cout << endl;
2828
});
2929
exit_status=process2.get_exit_status();
3030
cout << "Example 2 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
31-
std::this_thread::sleep_for(std::chrono::seconds(5));
31+
this_thread::sleep_for(chrono::seconds(5));
3232

3333

3434
cout << endl << "Example 3 - async sleep process" << endl;
35-
std::thread thread3([]() {
35+
thread thread3([]() {
3636
Process process3("sleep 5");
3737
auto exit_status=process3.get_exit_status();
3838
cout << "Example 3 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
3939
});
4040
thread3.detach();
41-
std::this_thread::sleep_for(std::chrono::seconds(10));
41+
this_thread::sleep_for(chrono::seconds(10));
4242

4343

4444
cout << endl << "Example 4 - killing async sleep process after 5 seconds" << endl;
45-
auto process4=std::make_shared<Process>("sleep 10");
46-
std::thread thread4([process4]() {
45+
auto process4=make_shared<Process>("sleep 10");
46+
thread thread4([process4]() {
4747
auto exit_status=process4->get_exit_status();
4848
cout << "Example 4 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
4949
});
5050
thread4.detach();
51-
std::this_thread::sleep_for(std::chrono::seconds(5));
51+
this_thread::sleep_for(chrono::seconds(5));
5252
process4->kill();
53-
std::this_thread::sleep_for(std::chrono::seconds(5));
53+
this_thread::sleep_for(chrono::seconds(5));
5454

5555

5656
cout << endl << "Example 5 - multiple commands, stdout and stderr" << endl;
5757
Process process5("echo Hello && ls an_incorrect_path", "", [](const char *bytes, size_t n) {
58-
cout << "Output from stdout: " << std::string(bytes, n);
58+
cout << "Output from stdout: " << string(bytes, n);
5959
}, [](const char *bytes, size_t n) {
60-
cout << "Output from stderr: " << std::string(bytes, n);
60+
cout << "Output from stderr: " << string(bytes, n);
6161
//add a newline for prettier output on some platforms:
6262
if(bytes[n-1]!='\n')
6363
cout << endl;
6464
});
6565
exit_status=process5.get_exit_status();
6666
cout << "Example 5 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
67-
std::this_thread::sleep_for(std::chrono::seconds(5));
67+
this_thread::sleep_for(chrono::seconds(5));
6868

6969

7070
cout << endl << "Example 6 - run bash with input from stdin" << endl;
7171
Process process6("bash", "", [](const char *bytes, size_t n) {
72-
cout << "Output from stdout: " << std::string(bytes, n);
72+
cout << "Output from stdout: " << string(bytes, n);
7373
}, nullptr, true);
7474
process6.write("echo Hello from bash\n");
7575
process6.write("exit\n");
7676
exit_status=process6.get_exit_status();
7777
cout << "Example 6 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
78-
std::this_thread::sleep_for(std::chrono::seconds(5));
78+
this_thread::sleep_for(chrono::seconds(5));
7979

8080

8181
cout << endl << "Example 7 - send data to cat through stdin" << endl;
8282
Process process7("cat", "", [](const char *bytes, size_t n) {
83-
cout << "Output from stdout: " << std::string(bytes, n);
83+
cout << "Output from stdout: " << string(bytes, n);
8484
}, nullptr, true);
8585
process7.write("Hello cat\n");
8686
process7.close_stdin();
8787
exit_status=process7.get_exit_status();
8888
cout << "Example 7 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
89-
std::this_thread::sleep_for(std::chrono::seconds(5));
89+
this_thread::sleep_for(chrono::seconds(5));
9090

9191

9292
#else
@@ -95,47 +95,47 @@ int main() {
9595

9696
cout << "Example 1 - the mandatory Hello World" << endl;
9797
Process process1("cmd /C echo Hello World", "", [](const char *bytes, size_t n) {
98-
cout << "Output from stdout: " << std::string(bytes, n);
98+
cout << "Output from stdout: " << string(bytes, n);
9999
});
100100
auto exit_status=process1.get_exit_status();
101101
cout << "Example 1 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
102-
std::this_thread::sleep_for(std::chrono::seconds(5));
102+
this_thread::sleep_for(chrono::seconds(5));
103103

104104

105105
cout << endl << "Example 2 - cd into a nonexistent directory" << endl;
106106
Process process2("cmd /C cd a_nonexistent_directory", "", [](const char *bytes, size_t n) {
107-
cout << "Output from stdout: " << std::string(bytes, n);
107+
cout << "Output from stdout: " << string(bytes, n);
108108
}, [](const char *bytes, size_t n) {
109-
cout << "Output from stderr: " << std::string(bytes, n);
109+
cout << "Output from stderr: " << string(bytes, n);
110110
//add a newline for prettier output on some platforms:
111111
if(bytes[n-1]!='\n')
112112
cout << endl;
113113
});
114114
exit_status=process2.get_exit_status();
115115
cout << "Example 2 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
116-
std::this_thread::sleep_for(std::chrono::seconds(5));
116+
this_thread::sleep_for(chrono::seconds(5));
117117

118118

119119
cout << endl << "Example 3 - async sleep process" << endl;
120-
std::thread thread3([]() {
120+
thread thread3([]() {
121121
Process process3("timeout 5");
122122
auto exit_status=process3.get_exit_status();
123123
cout << "Example 3 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
124124
});
125125
thread3.detach();
126-
std::this_thread::sleep_for(std::chrono::seconds(10));
126+
this_thread::sleep_for(chrono::seconds(10));
127127

128128

129129
cout << endl << "Example 4 - killing async sleep process after 5 seconds" << endl;
130-
auto process4=std::make_shared<Process>("timeout 10");
131-
std::thread thread4([process4]() {
130+
auto process4=make_shared<Process>("timeout 10");
131+
thread thread4([process4]() {
132132
auto exit_status=process4->get_exit_status();
133133
cout << "Example 4 process returned: " << exit_status << " (" << (exit_status==0?"success":"failure") << ")" << endl;
134134
});
135135
thread4.detach();
136-
std::this_thread::sleep_for(std::chrono::seconds(5));
136+
this_thread::sleep_for(chrono::seconds(5));
137137
process4->kill();
138-
std::this_thread::sleep_for(std::chrono::seconds(5));
138+
this_thread::sleep_for(chrono::seconds(5));
139139

140140

141141
#endif

0 commit comments

Comments
 (0)