forked from mamchits/phantom
-
Notifications
You must be signed in to change notification settings - Fork 23
/
size.H
59 lines (42 loc) · 1.5 KB
/
size.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// This file is part of the pd::base library.
// Copyright (C) 2006-2014, Eugene Mamchits <mamchits@yandex-team.ru>.
// Copyright (C) 2006-2014, YANDEX LLC.
// This library may be distributed under the terms of the GNU LGPL 2.1.
// See the file ‘COPYING’ or ‘http://www.gnu.org/licenses/lgpl-2.1.html’.
#pragma once
#include <pd/base/defs.H>
#include <stdint.h>
#pragma GCC visibility push(default)
namespace pd {
class sizeval_t {
uint64_t val;
public:
inline constexpr sizeval_t() throw() : val(0) { }
inline constexpr sizeval_t(uint64_t _val) throw() : val(_val) { }
inline constexpr sizeval_t(sizeval_t const &s) throw() : val(s.val) { }
~sizeval_t() = default;
inline sizeval_t &operator=(sizeval_t const &s) throw() {
val = s.val;
return *this;
}
inline sizeval_t &operator=(uint64_t _val) {
val = _val;
return *this;
}
inline operator uint64_t &() throw() { return val; }
inline constexpr operator uint64_t const &() const throw() { return val; }
static inline constexpr sizeval_t max() { return ~(uint64_t)0; }
static inline constexpr sizeval_t min() { return 0; }
};
namespace sizeval {
constexpr sizeval_t unit((uint64_t)1);
constexpr sizeval_t kilo(unit * 1024);
constexpr sizeval_t mega(kilo * 1024);
constexpr sizeval_t giga(mega * 1024);
constexpr sizeval_t tera(giga * 1024);
constexpr sizeval_t peta(tera * 1024);
constexpr sizeval_t exa(peta * 1024);
constexpr sizeval_t unlimited(sizeval_t::max());
} // namespace sizeval
} // namespace pd
#pragma GCC visibility pop