Skip to content

Commit df0e364

Browse files
committed
Update ex14_18_String.h
1 parent 14b2e59 commit df0e364

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

ch14/ex14_18_String.h

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,52 @@
2020

2121
class String
2222
{
23-
friend std::ostream& operator<<(std::ostream&, const String&);
24-
friend std::istream& operator>>(std::istream&, String&);
25-
friend bool operator==(const String&, const String&);
26-
friend bool operator!=(const String&, const String&);
27-
friend bool operator< (const String&, const String&);
28-
friend bool operator> (const String&, const String&);
29-
friend bool operator<=(const String&, const String&);
30-
friend bool operator>=(const String&, const String&);
23+
friend std::ostream& operator<<(std::ostream&, const String&);
24+
friend std::istream& operator>>(std::istream&, String&);
25+
friend bool operator==(const String&, const String&);
26+
friend bool operator!=(const String&, const String&);
27+
friend bool operator< (const String&, const String&);
28+
friend bool operator> (const String&, const String&);
29+
friend bool operator<=(const String&, const String&);
30+
friend bool operator>=(const String&, const String&);
3131

3232
public:
33-
String() : String("") {}
34-
String(const char *);
35-
String(const String&);
36-
String& operator=(const String&);
37-
String(String &&) NOEXCEPT;
38-
String& operator=(String&&) NOEXCEPT;
39-
~String();
33+
String() : String("") {}
34+
String(const char *);
35+
String(const String&);
36+
String& operator=(const String&);
37+
String(String &&) NOEXCEPT;
38+
String& operator=(String&&)NOEXCEPT;
39+
~String();
4040

41-
void push_back(const char);
41+
void push_back(const char);
4242

43-
char* begin() const { return elements; }
44-
char* end() const { return last_elem; }
43+
char* begin() const { return elements; }
44+
char* end() const { return last_elem; }
4545

46-
const char *c_str() const { return elements; }
47-
size_t size() const { return last_elem - elements; }
48-
size_t length() const { return size(); }
49-
size_t capacity() const { return cap - elements; }
46+
const char *c_str() const { return elements; }
47+
size_t size() const { return last_elem - elements; }
48+
size_t length() const { return size(); }
49+
size_t capacity() const { return cap - elements; }
5050

51-
void reserve(size_t);
52-
void resize(size_t);
53-
void resize(size_t, char);
51+
void reserve(size_t);
52+
void resize(size_t);
53+
void resize(size_t, char);
5454

5555
private:
56-
std::pair<char*, char*> alloc_n_copy(const char*, const char*);
57-
void range_initializer(const char*, const char*);
58-
void free();
59-
void reallocate();
60-
void alloc_n_move(size_t new_cap);
61-
void chk_n_alloc() { if (first_free == cap) reallocate(); }
56+
std::pair<char*, char*> alloc_n_copy(const char*, const char*);
57+
void range_initializer(const char*, const char*);
58+
void free();
59+
void reallocate();
60+
void alloc_n_move(size_t new_cap);
61+
void chk_n_alloc() { if (first_free == cap) reallocate(); }
6262

6363
private:
64-
char *elements;
65-
char *last_elem;
66-
char *first_free;
67-
char *cap;
68-
std::allocator<char> alloc;
64+
char *elements;
65+
char *last_elem;
66+
char *first_free;
67+
char *cap;
68+
std::allocator<char> alloc;
6969
};
7070

7171
std::ostream& operator<<(std::ostream&, const String&);

0 commit comments

Comments
 (0)