From 7b6c184e602d4ce04f1545ad0cbc16998a4fd8f9 Mon Sep 17 00:00:00 2001 From: Aleksandr Orefkov Date: Wed, 24 Sep 2025 01:35:12 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D1=85=D0=BE=D0=B4=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D0=B8=20Clang=20-=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BF=D0=B8=D0=BB=D1=8F=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?clang-cl=20=D0=B0=D1=82=D1=80=D0=B8=D0=B1=D1=83=D1=82=D1=8B=20e?= =?UTF-8?q?mpty=5Fbase=20=D0=B8=20no=5Funique=5Faddress=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D1=83=D0=B6=D0=B8=D0=B2=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D0=BC?= =?UTF-8?q?=D0=B5=D0=B6=D0=B4=D1=83=20=D1=81=D0=BE=D0=B1=D0=BE=D0=B9,=20?= =?UTF-8?q?=D0=B8=20=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=20=D1=8D=D0=BA?= =?UTF-8?q?=D0=B7=D0=B5=D0=BC=D0=BF=D0=BB=D1=8F=D1=80=D0=BE=D0=B2=20sstrin?= =?UTF-8?q?g=20/=20lstring=20=D1=83=D0=B2=D0=B5=D0=BB=D0=B8=D1=87=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D0=BD=D0=B0=208=20(4)?= =?UTF-8?q?=20=D0=BF=D1=83=D1=81=D1=82=D1=8B=D1=85=20=D0=B1=D0=B0=D0=B9?= =?UTF-8?q?=D1=82,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5?= =?UTF-8?q?=D0=BC=D1=8B=D1=85=20=D0=B2=20=D0=BD=D0=B0=D1=87=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/simstr/sstring.h | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/include/simstr/sstring.h b/include/simstr/sstring.h index 10aeeef..b8a6246 100644 --- a/include/simstr/sstring.h +++ b/include/simstr/sstring.h @@ -41,8 +41,10 @@ const bool isx64 = sizeof(void*) == 8; // NOLINT #ifdef _MSC_VER #define _no_unique_address msvc::no_unique_address +#define empty_bases __declspec(empty_bases) #else #define _no_unique_address no_unique_address +#define empty_bases #endif #if defined __has_builtin @@ -1733,12 +1735,6 @@ public: } }; -#ifdef _MSC_VER -#define empty_bases __declspec(empty_bases) -#else -#define empty_bases -#endif - /* * Базовая структура с информацией о строке. * Это структура для невладеющих строк. @@ -2311,24 +2307,21 @@ concept immutable_str = storable_str && !mutable_str; * какой-либо пустой класс. */ template -class str_storable { +class str_storable : protected Allocator { public: using my_type = Impl; using traits = ch_traits; using allocator_t = Allocator; protected: - [[_no_unique_address]] - allocator_t allocator_; - /*! * @brief Получить аллокатор */ allocator_t& allocator() { - return allocator_; + return *static_cast(this); } const allocator_t& allocator() const { - return allocator_; + return *static_cast(this); } using uni = unicode_traits; @@ -2341,7 +2334,7 @@ protected: } template requires std::is_constructible_v - explicit constexpr str_storable(size_t size, Args&&... args) : allocator_(std::forward(args)...) { + explicit constexpr str_storable(size_t size, Args&&... args) : Allocator(std::forward(args)...) { if (size) d().init(size); else @@ -2423,7 +2416,7 @@ public: template requires std::is_constructible_v constexpr str_storable(Args&&... args) noexcept(std::is_nothrow_constructible_v) - : allocator_(std::forward(args)...) { + : Allocator(std::forward(args)...) { d().create_empty(); } @@ -2434,7 +2427,7 @@ public: */ template requires std::is_constructible_v - constexpr str_storable(s_str other, Args&&... args) : allocator_(std::forward(args)...) { + constexpr str_storable(s_str other, Args&&... args) : Allocator(std::forward(args)...) { if (other.length()) { K* ptr = d().init(other.length()); traits::copy(ptr, other.symbols(), other.length()); @@ -2450,7 +2443,7 @@ public: */ template requires std::is_constructible_v - constexpr str_storable(size_t repeat, s_str pattern, Args&&... args) : allocator_(std::forward(args)...) { + constexpr str_storable(size_t repeat, s_str pattern, Args&&... args) : Allocator(std::forward(args)...) { size_t l = pattern.length(), allLen = l * repeat; if (allLen) { K* ptr = d().init(allLen); @@ -2470,7 +2463,7 @@ public: */ template requires std::is_constructible_v - str_storable(size_t count, K pad, Args&&... args) : allocator_(std::forward(args)...) { + str_storable(size_t count, K pad, Args&&... args) : Allocator(std::forward(args)...) { if (count) { K* str = d().init(count); traits::assign(str, count, pad); @@ -2488,7 +2481,7 @@ public: */ template requires std::is_constructible_v - constexpr str_storable(const StrExprForType auto& expr, Args&&... args) : allocator_(std::forward(args)...) { + constexpr str_storable(const StrExprForType auto& expr, Args&&... args) : Allocator(std::forward(args)...) { size_t len = expr.length(); if (len) *expr.place(d().init(len)) = 0; @@ -2507,7 +2500,7 @@ public: template From, typename... Args> requires std::is_constructible_v str_storable(const From& f, s_str pattern, s_str repl, size_t offset = 0, size_t maxCount = 0, Args&&... args) - : allocator_(std::forward(args)...) { + : Allocator(std::forward(args)...) { auto findes = f.find_all(pattern, offset, maxCount); if (!findes.size()) { @@ -4224,6 +4217,7 @@ constexpr const size_t local_count = _local_count; * - для u16s - 32 байта, хранит строки до 15 символов + 0 * - для u32s - 32 байта, хранит строки до 7 символов + 0 */ + template class empty_bases sstring : public str_algs, sstring, false>, @@ -5993,6 +5987,7 @@ using stringa = sstring; using stringw = sstring; using stringu = sstring; using stringuu = sstring; +static_assert(sizeof(stringa) == 24, "Bad size of sstring"); /*! * @brief Тип хеш-словаря для char строк, регистрозависимый поиск