Allow appending std::vector<bool>
std::vector<bool> when done with a for loop returns the type of
std::_bit_reference, which doesn't have a direct conversion to the
underlying boolean type.
Rather than relying on the type returned by begin(), rely on
T::value_type to specifically get the type in the container.
There isn't a particular use for this, but
https://gerrit.openbmc.org/c/openbmc/entity-manager/+/81474
Is trying to consolidate code, and having all types use the same
pack/unpack code is advantageous to avoid special cases. I don't
know of a place we're actually packing/unpacking arrays of bool.
Tested: Booted gb200nvl-bmc. Services launched, no new crashes seen.
Change-Id: I07fc150a190ae44f7bdc90531ad2a4ce7f47e0a1
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/test/message/append.cpp b/test/message/append.cpp
index bbba074..936454e 100644
--- a/test/message/append.cpp
+++ b/test/message/append.cpp
@@ -294,6 +294,21 @@
new_message().append(v);
}
+TEST_F(AppendTest, VectorBoolean)
+{
+ const std::vector<bool> v{false, true, false, true};
+ {
+ testing::InSequence seq;
+ expect_open_container(SD_BUS_TYPE_ARRAY, "b");
+ for (const auto& i : v)
+ {
+ expect_basic<bool>(SD_BUS_TYPE_BOOLEAN, (int)i);
+ }
+ expect_close_container();
+ }
+ new_message().append(v);
+}
+
TEST_F(AppendTest, VectorNestIntegral)
{
const std::vector<std::array<int32_t, 3>> v{