aboutsummaryrefslogtreecommitdiffstats
path: root/util/string
diff options
context:
space:
mode:
authorvadim-xd <vadim-xd@yandex-team.com>2023-11-20 13:40:41 +0300
committervadim-xd <vadim-xd@yandex-team.com>2023-11-20 15:28:24 +0300
commitcb92dabe792f1ce1ba168fdb3f5ad796736ab924 (patch)
treed783b31f157b0dbd587a86b7a068151c5040d51e /util/string
parent5ac396f8475fd70542f9812c6b3be50f79e873a4 (diff)
downloadydb-cb92dabe792f1ce1ba168fdb3f5ad796736ab924.tar.gz
Don't zero out unused bytes in TIntStringBuf at runtime
Diffstat (limited to 'util/string')
-rw-r--r--util/string/cast.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/util/string/cast.h b/util/string/cast.h
index 581a0c329b..f297cf2e5b 100644
--- a/util/string/cast.h
+++ b/util/string/cast.h
@@ -415,9 +415,15 @@ public:
template <std::enable_if_t<std::is_integral<T>::value, bool> = true>
explicit constexpr TIntStringBuf(T t) {
Size_ = Convert(t, Buf_, sizeof(Buf_));
- // Init the rest of the array,
- // otherwise constexpr copy and move constructors don't work due to uninitialized data access
- std::fill(Buf_ + Size_, Buf_ + sizeof(Buf_), '\0');
+#if __cplusplus >= 202002L // is_constant_evaluated is not supported by CUDA yet
+ if (std::is_constant_evaluated()) {
+#endif
+ // Init the rest of the array,
+ // otherwise constexpr copy and move constructors don't work due to uninitialized data access
+ std::fill(Buf_ + Size_, Buf_ + sizeof(Buf_), '\0');
+#if __cplusplus >= 202002L
+ }
+#endif
}
constexpr operator TStringBuf() const noexcept {