summaryrefslogtreecommitdiff
path: root/include/rtl/ustring.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-10-31 13:23:34 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-10-31 13:23:34 +0100
commit2e3f5c8dd3b21efe83269f603e26ac20f3adde64 (patch)
tree920b0a17b70f89f4b67bad1789869994fa1ec0e6 /include/rtl/ustring.hxx
parent1b98f38cfac2ac6caa7f178f70bcd9c5f74f16a4 (diff)
Prevent nonsensical comparations between OUString and nullptr_t
...now that 1b98f38 css.xml.sax.XAttributeList is broken by design 074defe Strange OUString null check a24105a Nonsensical OUString null check 9799fe3 Nonsensical OUString null check d6b9fea Nonsensical OUString null check f2de7d0 This apparently always wanted to check that _rChars.trim() is non-empty a8cfc97 SvxBrushItem::GetGraphicLink no longer returns a pointer are fixed. (OString didn't have this problem with overloaded operator ==/!=, but had a similar issue with nullptr_t that OUString in turn didn't have, f20162304d73bc01955e9ef6506c3bd1c7016c48 "Rule out OString(std::nullptr_t)".) Change-Id: I4ca0e1f5a911448e7bc9b8c5dddff5993d61ef18
Diffstat (limited to 'include/rtl/ustring.hxx')
-rw-r--r--include/rtl/ustring.hxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 5c097656c917..5880a98dfb7f 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -1588,6 +1588,17 @@ public:
friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
{ return !(operator == ( pStr1, rStr2 )); }
+#if defined LIBO_INTERNAL_ONLY
+ // Prevent the above overloads from being selected for nonsensical code like
+ //
+ // if (ouIdAttr == nullptr)
+ //
+ friend bool operator ==(OUString const &, std::nullptr_t) = delete;
+ friend bool operator ==(std::nullptr_t, OUString const &) = delete;
+ friend bool operator !=(OUString const &, std::nullptr_t) = delete;
+ friend bool operator !=(std::nullptr_t, OUString const &) = delete;
+#endif
+
friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
{ return rStr1.compareTo( rStr2 ) < 0; }
friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )