Add a tuple type for packing
At the top level, payload had the ability to pack a tuple, but it did it
by splitting it into its parts and packing those individually. But if
one of those parts was a tuple, it would fail. This moves the tuple
packing code into the packing templates so that it is possible to pack a
nested tuple of tuples.
Tested-by: newly written tuple unit tests pass
Change-Id: Icd80926314072df78b0083a823dcfb46e944e365
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/include/ipmid/message/pack.hpp b/include/ipmid/message/pack.hpp
index 8a9abe1..4314ac1 100644
--- a/include/ipmid/message/pack.hpp
+++ b/include/ipmid/message/pack.hpp
@@ -93,6 +93,17 @@
}
};
+/** @brief Specialization of PackSingle for std::tuple<T> */
+template <typename... T>
+struct PackSingle<std::tuple<T...>>
+{
+ static int op(Payload& p, const std::tuple<T...>& v)
+ {
+ return std::apply([&p](const T&... args) { return p.pack(args...); },
+ v);
+ }
+};
+
/** @brief Specialization of PackSingle for std::string
* represented as a UCSD-Pascal style string
*/