Field alignment hackery in Map<> that allows to reduce object sizes (see the following commits)

This commit is contained in:
Pavel Kirienko
2015-06-18 18:19:58 +03:00
parent 356f46d08a
commit 91ed3709eb
+8 -7
View File
@@ -40,18 +40,19 @@ class UAVCAN_EXPORT MapBase : Noncopyable
public:
struct KVPair
{
Value value; // Key and value are swapped because this may allow to reduce padding (depending on types)
Key key;
Value value;
KVPair()
: key()
, value()
KVPair() :
value(),
key()
{ }
KVPair(const Key& arg_key, const Value& arg_value)
: key(arg_key)
, value(arg_value)
KVPair(const Key& arg_key, const Value& arg_value) :
value(arg_value),
key(arg_key)
{ }
bool match(const Key& rhs) const { return rhs == key; }
};