blob: 29e599b133a96b6928b3ab1edc1e882adb6a205a (
plain) (
blame)
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
52
53
54
55
56
57
|
#ifndef BOOK_COUNT_HH
#define BOOK_COUNT_HH
#include <ostream>
namespace book_store::product {
class book_count {
public:
using book_count_type = std::size_t;
private:
book_count_type _count;
public:
book_count() = default;
book_count(book_count_type count) : _count(count) {}
[[nodiscard]] auto value() const noexcept -> book_count_type;
friend auto operator<<(std::ostream &output_stream,
const book_count &price) -> std::ostream & {
output_stream << price._count;
return output_stream;
}
friend auto operator==(const book_count &lhs, const book_count &rhs) -> bool {
return lhs._count == rhs._count;
}
friend auto operator+(const book_count &lhs,
const book_count &rhs) -> book_count {
return {lhs._count + rhs._count};
}
friend auto operator<(const book_count &lhs, const book_count &rhs) -> bool {
return lhs._count < rhs._count;
}
friend auto operator-(const book_count &lhs,
const book_count &rhs) -> book_count {
return {lhs._count - rhs._count};
}
friend auto operator%(const book_count &lhs,
const book_count &rhs) -> book_count {
return {lhs._count % rhs._count};
}
friend auto operator*(const book_count &lhs,
const book_count &rhs) -> book_count {
return {lhs._count * rhs._count};
}
};
} // namespace book_store::product
#endif // BOOK_COUNT_HH
|