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