summaryrefslogtreecommitdiffstats
path: root/test/message
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@us.ibm.com>2017-01-24 12:55:01 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-01-30 15:28:39 -0600
commit3306847106526b76af55513a0c1a5d974ede9c25 (patch)
tree00c5a608fe95a35c4d4b1a86515c4bb0f9b72235 /test/message
parentbc4afed4330dadec28b376b4e8e4784bdd7dcad7 (diff)
downloadsdbusplus-3306847106526b76af55513a0c1a5d974ede9c25.tar.gz
sdbusplus-3306847106526b76af55513a0c1a5d974ede9c25.zip
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>
Diffstat (limited to 'test/message')
-rw-r--r--test/message/native_types.cpp10
1 files changed, 10 insertions, 0 deletions
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 @@ int main()
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") };
OpenPOWER on IntegriCloud