[COMMIT seastar master] core/units: add user-defined literal for IEC prefixes

1 view
Skip to first unread message

Commit Bot

<bot@cloudius-systems.com>
unread,
Jan 26, 2023, 7:55:47 AM1/26/23
to seastar-dev@googlegroups.com, Kefu Chai
From: Kefu Chai <kefu...@scylladb.com>
Committer: Avi Kivity <a...@scylladb.com>
Branch: master

core/units: add user-defined literal for IEC prefixes

so we can use 42_MiB in place of '42 * 1024 * 1024'.

Signed-off-by: Kefu Chai <kefu...@scylladb.com>

---
diff --git a/include/seastar/core/units.hh b/include/seastar/core/units.hh
--- a/include/seastar/core/units.hh
+++ b/include/seastar/core/units.hh
@@ -29,4 +29,9 @@ static constexpr size_t KB = 1 << 10;
static constexpr size_t MB = 1 << 20;
static constexpr size_t GB = 1 << 30;

+constexpr size_t operator"" _KiB(unsigned long long n) { return n << 10; }
+constexpr size_t operator"" _MiB(unsigned long long n) { return n << 20; }
+constexpr size_t operator"" _GiB(unsigned long long n) { return n << 30; }
+constexpr size_t operator"" _TiB(unsigned long long n) { return n << 40; }
+
}
Reply all
Reply to author
Forward
0 new messages