forked from jaege/Cpp-Primer-5th-Exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StrBlob.h
43 lines (31 loc) · 842 Bytes
/
StrBlob.h
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
#ifndef STRBLOB_H
#define STRBLOB_H
class StrBlobPtr;
#include <vector>
#include <string>
#include <initializer_list>
#include <memory>
class StrBlob {
friend class StrBlobPtr;
public:
typedef std::vector<std::string>::size_type size_type;
StrBlob();
StrBlob(std::initializer_list<std::string> il);
size_type size() const { return data->size(); }
bool empty() const { return data->empty(); }
void push_back(const std::string &s);
void pop_back();
std::string &front();
const std::string &front() const;
std::string &back();
const std::string &back() const;
StrBlobPtr begin();
StrBlobPtr end();
private:
std::shared_ptr<std::vector<std::string>> data;
void check(size_type pos, const std::string &msg) const;
};
inline void StrBlob::push_back(const std::string &s) {
data->push_back(s);
}
#endif