summaryrefslogtreecommitdiff
path: root/include/rtl/string.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2023-03-16 11:52:29 +0100
committerStephan Bergmann <sbergman@redhat.com>2023-03-17 14:52:05 +0000
commitb8f131d4cc0454ffe4f809763ce6bccafeab3eb0 (patch)
tree840eabca87e4a0c902e9acf257c87019ee2569f4 /include/rtl/string.hxx
parent796c9c5ac2196e62546bcef229dcd08a3b8724db (diff)
Towards literal O[U]String types in C++20
...(where destructors can be constexpr), making 21584b304b21bfe6b99b6f29018c6b754ea28fc0 "make OUString(OUStringLiteral) constructor constexpr" and 983c1146ac80c038feae653e8e3752a72171d6cb "actually make OString(OStringLiteral) constructor constexpr" actually useful and eventually removing the need for O[U]StringConstExpr again Change-Id: I55520c1d928758f61e92336206e0f14b6f12a711 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148978 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/rtl/string.hxx')
-rw-r--r--include/rtl/string.hxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 0a90fc9f04a3..6af1a1a3b339 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -452,9 +452,22 @@ public:
/**
Release the string data.
*/
+#if defined LIBO_INTERNAL_ONLY && __cplusplus >= 202002L
+ constexpr
+#endif
~OString()
{
- rtl_string_release( pData );
+#if defined LIBO_INTERNAL_ONLY && __cplusplus >= 202002L
+ if (std::is_constant_evaluated()) {
+ //TODO: We would want to
+ //
+ // assert(SAL_STRING_IS_STATIC(pData));
+ //
+ // here, but that wouldn't work because read of member `str` of OUStringLiteral's
+ // anonymous union with active member `more` is not allowed in a constant expression.
+ } else
+#endif
+ rtl_string_release( pData );
}
#if defined LIBO_INTERNAL_ONLY