From 01de5d42afdaae5348a2ca2e9f47bdf038d29b11 Mon Sep 17 00:00:00 2001 From: vadim-xd Date: Tue, 19 May 2026 10:43:11 +0300 Subject: Add Concat for arbitrary string types commit_hash:b9f1c87173a18fb59f8cf684191efd4436dd6012 --- library/cpp/containers/cow_string/cow_string.h | 40 +++----------------------- 1 file changed, 4 insertions(+), 36 deletions(-) (limited to 'library/cpp') diff --git a/library/cpp/containers/cow_string/cow_string.h b/library/cpp/containers/cow_string/cow_string.h index 0ffea0ac2bf..34dcff81e8a 100644 --- a/library/cpp/containers/cow_string/cow_string.h +++ b/library/cpp/containers/cow_string/cow_string.h @@ -321,44 +321,12 @@ public: } private: - template - using TJoinParam = std::conditional_t, TCharType, TBasicStringBuf>; - - template - static size_t SumLength(const TBasicStringBuf s1, const R&... r) noexcept { - return s1.size() + SumLength(r...); - } - - template - static size_t SumLength(const TCharType /*s1*/, const R&... r) noexcept { - return 1 + SumLength(r...); - } - - static constexpr size_t SumLength() noexcept { - return 0; - } - - template - static void CopyAll(TCharType* p, const TBasicStringBuf s, const R&... r) { - TTraits::copy(p, s.data(), s.size()); - CopyAll(p + s.size(), r...); - } - - template ::value>> - static void CopyAll(TCharType* p, const TNextCharType s, const R&... r) { - p[0] = s; - CopyAll(p + 1, r...); - } - - static void CopyAll(TCharType*) noexcept { - } + using TJoinHelper = TStringJoinHelper; template static inline TBasicCowString JoinImpl(const R&... r) { - TBasicCowString s{TUninitialized{SumLength(r...)}}; - - TBasicCowString::CopyAll((TCharType*)s.data(), r...); - + TBasicCowString s{TUninitialized{TJoinHelper::SumLength(r...)}}; + TJoinHelper::CopyAll((TCharType*)s.data(), r...); return s; } @@ -375,7 +343,7 @@ public: template static inline TBasicCowString Join(const R&... r) { - return JoinImpl(TJoinParam(r)...); + return JoinImpl(typename TJoinHelper::template TJoinParam(r)...); } // ~~~ Assignment ~~~ : FAMILY0(TBasicCowString&, assign); -- cgit v1.3