From 2c78fcdc4e099ef44d866e0709cdec6c308a89fc Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Mon, 6 Apr 2015 00:15:51 +0300 Subject: [PATCH] clean up byteorder.hh byteorder.hh's "net::packed" subclassed the basic unaligned and added a "adjust_endianess" method. This was completely unnecessary: While ntoh's generic implementation indeed uses that method, we also have a specialized overload for ntoh(packed), so the generic implementation would never be used for packed anyway! So for net::packed we don't need anything more than unaligned, and can just make it an alias. As a bonus, the "hton" function will now work also on unaligned (such as the result of the convenient unaligned_cast<>), not just on net::packed. Signed-off-by: Nadav Har'El --- net/byteorder.hh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/net/byteorder.hh b/net/byteorder.hh index a3f8c40406..52f29f76b9 100644 --- a/net/byteorder.hh +++ b/net/byteorder.hh @@ -58,13 +58,9 @@ inline int32_t hton(int32_t x) { return htonl(x); } inline int64_t ntoh(int64_t x) { return ntohq(x); } inline int64_t hton(int64_t x) { return htonq(x); } -// Define net::packed<> using unaligned<> from unaligned.hh. -template -struct packed : public unaligned { - using unaligned::unaligned; // inherit constructors - template - void adjust_endianness(Adjuster a) { a(this->raw); } -} __attribute__((packed)); +// Deprecated alias net::packed<> for unaligned<> from unaligned.hh. +// TODO: get rid of this alias. +template using packed = unaligned; template inline T ntoh(const packed& x) {