-
Notifications
You must be signed in to change notification settings - Fork 34
/
literals.hpp
37 lines (27 loc) · 1020 Bytes
/
literals.hpp
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
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <cstdint>
namespace kagome::common::literals {
constexpr std::size_t operator""_kB(long long unsigned int kilobytes) {
return static_cast<std::size_t>(kilobytes << 10u);
}
constexpr std::size_t operator""_kB(long double kilobytes) {
return static_cast<std::size_t>((1ull << 10ull) * kilobytes);
}
constexpr std::size_t operator""_MB(long long unsigned int megabytes) {
return static_cast<std::size_t>(megabytes << 20ull);
}
constexpr std::size_t operator""_MB(long double megabytes) {
return static_cast<std::size_t>((1ull << 20ull) * megabytes);
}
constexpr std::size_t operator""_GB(long long unsigned int gigabytes) {
return static_cast<std::size_t>(gigabytes << 30ull);
}
constexpr std::size_t operator""_GB(long double gigabytes) {
return static_cast<std::size_t>((1ull << 30ull) * gigabytes);
}
} // namespace kagome::common::literals