-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (35 loc) · 1.57 KB
/
Copy pathmain.cpp
File metadata and controls
44 lines (35 loc) · 1.57 KB
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
#include <iostream>
#include <utility>
#include "MyString.h"
int main() {
MyString language("Modern C++17");
MyString project("MyString");
std::cout << "=== MyString demo ===\n";
std::cout << "language : " << language << '\n';
std::cout << "project : " << project << '\n';
MyString combined = language + MyString(" - ");
combined += project;
std::cout << "combined : " << combined << '\n';
std::cout << "size : " << combined.size() << '\n';
std::cout << "capacity : " << combined.capacity() << '\n';
combined += " library";
std::cout << "append : " << combined << '\n';
std::cout << "find : " << combined.find(MyString("String")) << '\n';
std::cout << "contains : " << std::boolalpha << combined.contains(MyString("C++")) << '\n';
std::cout << "prefix : " << combined.starts_with(MyString("Modern")) << '\n';
std::cout << "suffix : " << combined.ends_with(MyString("library")) << '\n';
std::cout << "substr : " << combined.substr(7, 5) << '\n';
std::cout << "reverse : " << combined.reversed() << '\n';
MyString copied(combined);
copied[0] = 'm';
std::cout << "copy : " << copied << '\n';
std::cout << "original : " << combined << '\n';
MyString moved(std::move(copied));
std::cout << "moved : " << moved << '\n';
std::cout << "moved-from size: " << copied.size() << '\n';
MyString cleared = combined;
cleared.clear();
std::cout << "cleared : \"" << cleared << "\" (empty=" << cleared.empty() << ")\n";
std::cout << "=== demo complete ===\n";
return 0;
}