/Users/deen/code/yugabyte-db/src/yb/util/size_literals.h
Line | Count | Source |
1 | | // |
2 | | // Copyright (c) YugaByte, Inc. |
3 | | // |
4 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
5 | | // in compliance with the License. You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
10 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
11 | | // or implied. See the License for the specific language governing permissions and limitations |
12 | | // under the License. |
13 | | // |
14 | | // |
15 | | #ifndef YB_UTIL_SIZE_LITERALS_H |
16 | | #define YB_UTIL_SIZE_LITERALS_H |
17 | | |
18 | | #include <stddef.h> |
19 | | |
20 | | namespace yb { |
21 | | |
22 | | namespace size_literals { |
23 | | |
24 | 90.9M | inline constexpr size_t operator "" _KB(unsigned long long kilobytes) { // NOLINT |
25 | 90.9M | return kilobytes * 1024; |
26 | 90.9M | } |
27 | | |
28 | 29.6M | inline constexpr size_t operator "" _MB(unsigned long long megabytes) { // NOLINT |
29 | 29.6M | return megabytes * 1024 * 1024; |
30 | 29.6M | } |
31 | | |
32 | 97 | inline constexpr size_t operator "" _GB(unsigned long long gigabytes) { // NOLINT |
33 | 97 | return gigabytes * 1024 * 1024 * 1024; |
34 | 97 | } |
35 | | |
36 | | } // namespace size_literals |
37 | | |
38 | | using size_literals::operator"" _KB; |
39 | | using size_literals::operator"" _MB; |
40 | | using size_literals::operator"" _GB; |
41 | | |
42 | | } // namespace yb |
43 | | |
44 | | #endif // YB_UTIL_SIZE_LITERALS_H |