@@ -658,7 +658,7 @@ class str_algs : public buffer_pointers<K, Impl, Mutable> {
658658 }
659659 /* !
660660 * @ru @brief Размер строки в символах.
661- * @return size_t
661+ * @return size_t
662662 * @en @brief The size of the string in characters.
663663 * @return size_t
664664 */
@@ -690,7 +690,8 @@ class str_algs : public buffer_pointers<K, Impl, Mutable> {
690690 * @en @brief Convert to std::string_view.
691691 * @return std::string_view.
692692 */
693- std::string_view to_sv () const noexcept {
693+ template <typename =int > requires is_one_of_std_char_v<K>
694+ std::basic_string_view<K> to_sv () const noexcept {
694695 return {_str (), _len ()};
695696 }
696697 /* !
@@ -699,7 +700,8 @@ class str_algs : public buffer_pointers<K, Impl, Mutable> {
699700 * @en @brief Convert to std::string.
700701 * @return std::string.
701702 */
702- std::string to_string () const noexcept {
703+ template <typename =int > requires is_one_of_std_char_v<K>
704+ std::basic_string<K> to_string () const noexcept {
703705 return {_str (), _len ()};
704706 }
705707 /* !
@@ -1090,7 +1092,7 @@ class str_algs : public buffer_pointers<K, Impl, Mutable> {
10901092 // We don't look for an empty line or a line longer than the text.
10911093 if (!lenPattern || lenPattern > lenText)
10921094 return str::npos;
1093-
1095+
10941096 lenPattern--;
10951097 const K *text = _str () + lenPattern, last = pattern[lenPattern];
10961098 lenText -= lenPattern;
@@ -2312,7 +2314,7 @@ struct simple_str_nt : simple_str<K> {
23122314 * @details Это единственный конструктор из всех строковых объектов, принимающий C-строку.
23132315 * Вычисляет её длину при инициализации. Все остальные строковые объекты не инициализируются
23142316 * C-строками. Это для того, чтобы `strlen` вызывалась только в одном месте библиотеки,
2315- * длина C-строки вычислялась только один раз и далее не терялась случайно при передаче между разными
2317+ * длина C-строки вычислялась только один раз и далее не терялась случайно при передаче между разными
23162318 * типами строковых объектов.
23172319 * @en @brief Explicit constructor from C-string.
23182320 * @param p - pointer to a C-string (null-terminated string).
@@ -4352,7 +4354,7 @@ class str_mutable {
43524354 from = size;
43534355 size_t capacity = d ().capacity ();
43544356 K* ptr = str ();
4355-
4357+
43564358 auto result = std::format_to (writer{d (), ptr + from, ptr + capacity, size_t (-1 )},
43574359 std::forward<decltype (format)>(format), std::forward<T>(args)...);
43584360 d ().set_size (result.ptr - _str ());
@@ -4800,12 +4802,12 @@ class decl_empty_bases lstring :
48004802 lstring (const Op& op, Args&&... args) : base_storable(std::forward<Args>(args)...) {
48014803 this ->operator <<(op);
48024804 }
4803-
4805+
48044806 // copy and swap для присваиваний здесь не очень применимо, так как для строк с большим локальным буфером лишняя копия даже перемещением будет дорого стоить
48054807 // Поэтому реализуем копирующее и перемещающее присваивание отдельно
48064808 // copy and swap for assignments is not very applicable here, since for strings with a large local buffer, an extra copy, even by moving, will be expensive
48074809 // Therefore, we implement the copy and move assignment separately
4808-
4810+
48094811 /* !
48104812 * @ru @brief Оператор присваивания копией из строки такого же типа.
48114813 * @param other - другая строка.
@@ -5682,22 +5684,32 @@ consteval simple_str_nt<K> select_str(simple_str_nt<u8s> s8, simple_str_nt<uws>
56825684
56835685#define uni_string (K, p ) select_str<K>(p, L##p, u##p, U##p)
56845686
5685- template <typename K> requires (is_one_of_std_char_v<K>)
5687+ template <typename K>
56865688struct expr_real {
56875689 using symb_type = K;
5688- mutable K buf[40 ];
5690+ mutable std:: conditional_t <is_one_of_std_char_v<K>, K, u8s> buf[40 ];
56895691 mutable size_t l;
56905692 double v;
56915693 expr_real (double d) : v(d) {}
56925694 expr_real (float d) : v(d) {}
56935695
56945696 size_t length () const noexcept {
5695- printf_selector::snprintf (buf, 40 , uni_string (K, " %.16g" ).str , v);
5696- l = (size_t )ch_traits<K>::length (buf);
5697+ if constexpr (is_one_of_std_char_v<K>) {
5698+ printf_selector::snprintf (buf, 40 , uni_string (K, " %.16g" ).str , v);
5699+ l = (size_t )ch_traits<K>::length (buf);
5700+ } else {
5701+ l = std::snprintf (buf, sizeof (buf), " %.16g" , v);
5702+ }
56975703 return l;
56985704 }
56995705 K* place (K* ptr) const noexcept {
5700- ch_traits<K>::copy (ptr, buf, l);
5706+ if constexpr (is_one_of_std_char_v<K>) {
5707+ ch_traits<K>::copy (ptr, buf, l);
5708+ } else {
5709+ for (size_t i = 0 ; i < l; i++) {
5710+ ptr[i] = buf[i];
5711+ }
5712+ }
57015713 return ptr + l;
57025714 }
57035715};
@@ -5714,7 +5726,7 @@ struct expr_real {
57145726 * @details The number is converted to a string representation via sprintf("%.16g").
57155727 */
57165728template <StrExpr A, typename R>
5717- requires (is_one_of_std_char_v< typename A::symb_type> && ( std::is_same_v<R, double > || std::is_same_v<R, float >) )
5729+ requires (std::is_same_v<R, double > || std::is_same_v<R, float >)
57185730inline constexpr auto operator +(const A& a, R s) {
57195731 return strexprjoin_c<A, expr_real<typename A::symb_type>>{a, s};
57205732}
@@ -6204,7 +6216,7 @@ struct expr_replace_symbols {
62046216 ch_traits<K>::copy (ptr, text + start, tail);
62056217 return ptr + tail;
62066218 }
6207-
6219+
62086220protected:
62096221 size_t index_of (K s) const {
62106222 return pattern_.find (s);
@@ -6354,7 +6366,7 @@ struct expr_replace_const_symbols {
63546366 ch_traits<K>::copy (ptr, text + start, tail);
63556367 return ptr + tail;
63566368 }
6357-
6369+
63586370protected:
63596371 template <typename ... Repl>
63606372 constexpr expr_replace_const_symbols (int , simple_str<K> source, K s, simple_str<K> r, Repl&&... repl) :
@@ -6684,7 +6696,7 @@ class hashStrMap : public std::unordered_map<StoreType<K, H>, T, H, E> {
66846696 }
66856697
66866698 hashStrMap (my_type&& o) = default ;
6687-
6699+
66886700 my_type& operator =(const my_type& other) {
66896701 hash_t ::operator =(other);
66906702 for (const auto & [k, v] : *this ) {
@@ -6818,15 +6830,6 @@ class hashStrMap : public std::unordered_map<StoreType<K, H>, T, H, E> {
68186830 return erase (toStoreType (key));
68196831 }
68206832
6821- bool lookup (const K* txt, T& val) const {
6822- auto it = find (e_s (txt));
6823- if (it != hash_t::end ()) {
6824- val = it->second ;
6825- return true ;
6826- }
6827- return false ;
6828- }
6829-
68306833 bool lookup (simple_str<K> txt, T& val) const {
68316834 auto it = find (txt);
68326835 if (it != hash_t::end ()) {
@@ -7482,7 +7485,7 @@ inline HashKeyIU<uws> operator""_iu(const uws* ptr, size_t l) {
74827485 * @ru @brief Оператор вывода в поток simple_str.
74837486 * @param stream - поток вывода.
74847487 * @param text - текст.
7485- * @return std::ostream&.
7488+ * @return std::ostream&.
74867489 * @en @brief Stream output operator simple_str.
74877490 * @param stream - output stream.
74887491 * @param text - text.
0 commit comments