sandbox
Loading...
Searching...
No Matches
bytes.hpp
1
#ifndef LIBSBX_UNITS_BYTES_HPP_
2
#define LIBSBX_UNITS_BYTES_HPP_
3
4
#include <libsbx/units/quantity.hpp>
5
6
namespace
sbx::units {
7
8
namespace
detail {
9
10
struct
byte_tag
{ };
11
12
}
// namespace detail
13
14
using
kibi = std::ratio<1024>;
15
using
mebi = std::ratio<1024 * 1024>;
16
using
gibi = std::ratio<1024 * 1024 * 1024>;
17
18
using
gibibyte
=
quantity<detail::byte_tag, std::uint64_t, gibi>
;
19
using
gigabyte
=
quantity<detail::byte_tag, std::uint64_t, std::giga>
;
20
using
mebibyte
=
quantity<detail::byte_tag, std::uint64_t, mebi>
;
21
using
megabyte
=
quantity<detail::byte_tag, std::uint64_t, std::mega>
;
22
using
kibibyte
=
quantity<detail::byte_tag, std::uint64_t, kibi>
;
23
using
kilobyte
=
quantity<detail::byte_tag, std::uint64_t, std::kilo>
;
24
using
byte
=
quantity<detail::byte_tag, std::uint64_t>
;
25
26
namespace
literals {
27
28
constexpr
auto
operator
""
_gib(
unsigned
long
long
value) ->
gibibyte
{
29
return
gibibyte
{value};
30
}
31
32
constexpr
auto
operator
""
_gb(
unsigned
long
long
value) -> gigabyte {
33
return
gigabyte{value};
34
}
35
36
constexpr
auto
operator
""
_mib(
unsigned
long
long
value) -> mebibyte {
37
return
mebibyte{value};
38
}
39
40
constexpr
auto
operator
""
_mb(
unsigned
long
long
value) -> megabyte {
41
return
megabyte{value};
42
}
43
44
constexpr
auto
operator
""
_kib(
unsigned
long
long
value) -> kibibyte {
45
return
kibibyte{value};
46
}
47
48
constexpr
auto
operator
""
_kb(
unsigned
long
long
value) -> kilobyte {
49
return
kilobyte{value};
50
}
51
52
constexpr
auto
operator
""
_b(
unsigned
long
long
value) ->
byte
{
53
return
byte
{value};
54
}
55
56
}
// namespace literals
57
58
}
// namespace sbx::units
59
60
#endif
// LIBSBX_UNITS_BYTES_HPP_
sbx::units::quantity
Definition:
quantity.hpp:65
sbx::units::detail::byte_tag
Definition:
bytes.hpp:10
libsbx-units
libsbx
units
bytes.hpp
Generated by
1.9.5