Bug 1344629 - Part 6.5: Allow get() on nsLiteralStrings, excluding temporaries. r=dbaron

This prevents the antipattern found in bug 1341513.

MozReview-Commit-ID: JhxgC7aQDUA

--HG--
extra : rebase_source : b1ff0d240df87b2cbb415183dc93acc8bde7960a
This commit is contained in:
David Major 2017-03-14 15:26:36 +13:00
parent 40f4821701
commit 9236e31186

View File

@ -33,6 +33,21 @@ public:
{
}
/**
* Prohibit get() on temporaries as in nsLiteralCString("x").get().
* These should be written as just "x", using a string literal directly.
*/
#if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
char16ptr_t get() const && = delete;
char16ptr_t get() const &
#else
const char_type* get() const && = delete;
const char_type* get() const &
#endif
{
return mData;
}
private:
// NOT TO BE IMPLEMENTED