-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbasics.cpp
More file actions
51 lines (36 loc) · 1 KB
/
basics.cpp
File metadata and controls
51 lines (36 loc) · 1 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
45
46
47
48
49
50
51
#include "basics.hpp"
namespace basics {
namespace {
std::size_t & internal_secret_count() {
static std::size_t count = 0;
return count;
}
} // anonymous
Secret::Secret() : _index(++internal_secret_count()) {}
bool compare(Secret const & a, Secret const & b) {
return a._index == b._index;
}
bool adjacent(Secret const & a, Secret const & b) {
return a._index + 1u == b._index;
}
Doodad::Doodad(std::string const & name_, int value_) :
name(name_), value(value_)
{}
Doodad::Doodad(WhatsIt const & it) : name(it.a), value(it.b) {}
Doodad::~Doodad() {}
std::unique_ptr<Doodad> Doodad::clone() const {
return std::unique_ptr<Doodad>(new Doodad(name, value));
}
void Doodad::read(WhatsIt const & it) {
name = it.a;
value = it.b;
}
WhatsIt Doodad::write() const {
WhatsIt it = {name, value};
return it;
}
std::shared_ptr<Doodad const> Doodad::get_const() {
static std::shared_ptr<Doodad const> instance(new Doodad("frozen", 50));
return instance;
}
} // namespace basics