compiler error : get_if<> with a variant enum ?

Patrick Williams patrick at stwcx.xyz
Tue Oct 18 10:37:15 AEDT 2022


On Mon, Oct 17, 2022 at 08:13:20AM +0000, Francine Sauvage wrote:
> 
> const auto* flexible_module_type = std::get_if<sdbusplus::xyz::openbmc_project::Inventory::Item::server::FlexibleModule::ModuleTypes>(&flexible_prop_map_iterator->second);
> 
> ** I tried to replace auto with sdbusplus::xyz::openbmc_project::Inventory::Item::server::FlexibleModule::ModuleTypes>
> No success.
> 
> Error is :
> 
> bmcweb/1.0+git1.0-r0/recipe-sysroot/usr/include/c++/10.2.0/variant:1150:42: error: static assertion failed: T must occur exactly once in alternatives
> static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,

What type is `flexible_prop_map_iterator->second`?  It seems likely it
is a variant that doesn't have the enumeration type in the list of
contained types.  "T must occur exactly one in alternatives" seems to be
saying that `ModuleTypes` wasn't part of the underlying variant types.

-- 
Patrick Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20221017/37754718/attachment-0001.sig>


More information about the openbmc mailing list