Allow implicit string_wrapper conversions
Add comparison operators to allow string_wrappers
to be implicity converted to strings for comparisons to
cut down on casting and/or str member access.
Do not allow std::string to be impliclitly converted
to object_path to avoid a temporary string copy.
Change-Id: I2e45a4fc3ee07d1df55f6fab2cfa35da205c150e
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/test/message/native_types.cpp b/test/message/native_types.cpp
index df1cb96..cbe33eb 100644
--- a/test/message/native_types.cpp
+++ b/test/message/native_types.cpp
@@ -4,6 +4,14 @@
#include <map>
#include <unordered_map>
+void check_string_compares(const sdbusplus::message::signature& sig,
+ const std::string& str)
+{
+ assert(sig == str);
+ assert(str == sig);
+ return;
+}
+
int main()
{
std::string s1 = sdbusplus::message::object_path("/asdf/");
@@ -12,6 +20,8 @@
std::string s2 = sdbusplus::message::signature("iii");
sdbusplus::message::signature sig = s2;
+ check_string_compares(sig, s2);
+
std::vector<sdbusplus::message::signature> v =
{ sdbusplus::message::signature("iii") };