server: object: reduce potential warnings
Some compilers and linters are not handling C++20 requirements
similarly and one, rightly, complains when the object class is
used that:
object.hpp:198:34: error: parameter type '...' is an abstract class
An abstract class cannot be a variable or function parameter, but a
reference to one can be. Switch the require statement to check a
`T&` instead of a `T` for the `emit_added` function calls.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iaad189c37c4962193cfa94cd777e385686e5a9da
diff --git a/include/sdbusplus/server/object.hpp b/include/sdbusplus/server/object.hpp
index c86598b..d0d3fd0 100644
--- a/include/sdbusplus/server/object.hpp
+++ b/include/sdbusplus/server/object.hpp
@@ -195,12 +195,12 @@
void try_emit()
{
// If T is a normal class with emit_added, call it.
- if constexpr (requires(T t) { t.emit_added(); })
+ if constexpr (requires(T & t) { t.emit_added(); })
{
this->T::emit_added();
}
// If T is a recursive object_t, call its maybe_emit_iface_added.
- if constexpr (requires(T t) { t.maybe_emit_iface_added(); })
+ if constexpr (requires(T & t) { t.maybe_emit_iface_added(); })
{
this->T::maybe_emit_iface_added();
}