[gnoduino: 26/237] Adding additional String + operators for disambiguation.
- From: Lucian Langa <lucilanga src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnoduino: 26/237] Adding additional String + operators for disambiguation.
- Date: Sat, 31 Mar 2012 20:17:00 +0000 (UTC)
commit ffc1a59677740d713164d1533d04e6d6ba80c348
Author: David A. Mellis <d mellis arduino cc>
Date: Sun Mar 13 19:31:10 2011 -0400
Adding additional String + operators for disambiguation.
The operator bool() means that you could implicitly convert a String to a bool and then add it to it an int, for example. Which means our operator+ has to match exactly or it will be ambiguous.
arduino/cores/arduino/WString.h | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/arduino/cores/arduino/WString.h b/arduino/cores/arduino/WString.h
index 5e78ee5..5a35101 100644
--- a/arduino/cores/arduino/WString.h
+++ b/arduino/cores/arduino/WString.h
@@ -175,5 +175,40 @@ public:
StringSumHelper(unsigned long num) : String(num, 10) {}
};
+inline StringSumHelper operator + (const String &lhs, const String &rhs)
+ { return StringSumHelper(lhs) + rhs; }
+
+inline StringSumHelper operator + (const String &lhs, const char *cstr)
+ { return StringSumHelper(lhs) + cstr; }
+inline StringSumHelper operator + (const String &lhs, char c)
+ { return StringSumHelper(lhs) + c; }
+inline StringSumHelper operator + (const String &lhs, unsigned char c)
+ { return StringSumHelper(lhs) + c; }
+inline StringSumHelper operator + (const String &lhs, int num)
+ { return StringSumHelper(lhs) + num; }
+inline StringSumHelper operator + (const String &lhs, unsigned int num)
+ { return StringSumHelper(lhs) + num; }
+inline StringSumHelper operator + (const String &lhs, long num)
+ { return StringSumHelper(lhs) + num; }
+inline StringSumHelper operator + (const String &lhs, unsigned long num)
+ { return StringSumHelper(lhs) + num; }
+
+inline StringSumHelper operator + (const char *cstr, const String &rhs)
+ { return StringSumHelper(cstr) + rhs; }
+inline StringSumHelper operator + (char c, const String &rhs)
+ { return StringSumHelper(c) + rhs; }
+inline StringSumHelper operator + (unsigned char c, const String &rhs)
+ { return StringSumHelper(c) + rhs; }
+inline StringSumHelper operator + (int num, const String &rhs)
+ { return StringSumHelper(num) + rhs; }
+inline StringSumHelper operator + (unsigned int num, const String &rhs)
+ { return StringSumHelper(num) + rhs; }
+inline StringSumHelper operator + (long num, const String &rhs)
+ { return StringSumHelper(num) + rhs; }
+inline StringSumHelper operator + (unsigned long num, const String &rhs)
+ { return StringSumHelper(num) + rhs; }
+
+
+
#endif // __cplusplus
#endif // String_class_h
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]