no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / mfbt / Literals.h
blobd1d403afaeb363e8eb3b8351e24ed23352c1e034
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Helpers for units on integer literals. */
9 #ifndef mozilla_Literals_h
10 #define mozilla_Literals_h
12 #include <cstddef>
14 // User-defined literals to make constants more legible. Use them by
15 // appending them to literals such as:
17 // size_t page_size = 4_KiB;
19 constexpr size_t operator"" _KiB(unsigned long long int aNum) {
20 return size_t(aNum) * 1024;
23 constexpr size_t operator"" _KiB(long double aNum) {
24 return size_t(aNum * 1024);
27 constexpr size_t operator"" _MiB(unsigned long long int aNum) {
28 return size_t(aNum) * 1024_KiB;
31 constexpr size_t operator"" _MiB(long double aNum) {
32 return size_t(aNum * 1024_KiB);
35 constexpr double operator""_percent(long double aPercent) {
36 return double(aPercent) / 100;
39 #endif /* ! mozilla_Literals_h */