forked from Kistler-Group/sdbus-cpp
feat: add std::variant constructor and conversion operator to sdbus::Variant (#429)
Signed-off-by: Anthony Brandon <anthony@amarulasolutions.com>
This commit is contained in:
@@ -65,6 +65,14 @@ namespace sdbus {
|
||||
msg_.seal();
|
||||
}
|
||||
|
||||
template <typename... _Elements>
|
||||
Variant(const std::variant<_Elements...>& value)
|
||||
: Variant()
|
||||
{
|
||||
msg_ << value;
|
||||
msg_.seal();
|
||||
}
|
||||
|
||||
template <typename _ValueType>
|
||||
_ValueType get() const
|
||||
{
|
||||
@@ -83,6 +91,15 @@ namespace sdbus {
|
||||
return get<_ValueType>();
|
||||
}
|
||||
|
||||
template <typename... _Elements>
|
||||
operator std::variant<_Elements...>() const
|
||||
{
|
||||
std::variant<_Elements...> result;
|
||||
msg_.rewind(false);
|
||||
msg_ >> result;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename _Type>
|
||||
bool containsValueOfType() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user