From fbfe0550769ddf9523657277ec3ba95aaf070b91 Mon Sep 17 00:00:00 2001 From: LIU Hao Date: Sun, 11 Feb 2024 16:26:24 +0800 Subject: [PATCH] rocket/cow_string: Remove excess overloads --- rocket/cow_string.hpp | 408 +----------------------------------------- 1 file changed, 1 insertion(+), 407 deletions(-) diff --git a/rocket/cow_string.hpp b/rocket/cow_string.hpp index 179b4735a..2ca840c2e 100644 --- a/rocket/cow_string.hpp +++ b/rocket/cow_string.hpp @@ -579,18 +579,6 @@ class basic_cow_string } // 24.3.2.6, modifiers - basic_cow_string& - append(shallow_type sh) - { - return this->append(sh.data(), sh.size()); - } - - basic_cow_string& - append(initializer_list init) - { - return this->append(init.begin(), init.size()); - } - basic_cow_string& append(const basic_cow_string& other, size_type pos = 0, size_type n = npos) { @@ -715,18 +703,6 @@ class basic_cow_string return *this; } - basic_cow_string& - operator+=(shallow_type sh) & - { - return this->append(sh); - } - - basic_cow_string& - operator+=(initializer_list init) & - { - return this->append(init); - } - basic_cow_string& operator+=(const basic_cow_string& other) & { @@ -745,18 +721,6 @@ class basic_cow_string return this->push_back(c); } - basic_cow_string& - operator<<(shallow_type sh) & - { - return this->append(sh); - } - - basic_cow_string& - operator<<(initializer_list init) & - { - return this->append(init); - } - basic_cow_string& operator<<(const basic_cow_string& other) & { @@ -775,18 +739,6 @@ class basic_cow_string return this->push_back(c); } - basic_cow_string&& - operator<<(shallow_type sh) && - { - return move(this->append(sh)); - } - - basic_cow_string&& - operator<<(initializer_list init) && - { - return move(this->append(init)); - } - basic_cow_string&& operator<<(const basic_cow_string& other) && { @@ -817,30 +769,6 @@ class basic_cow_string return move(this->pop_back(n)); } - basic_cow_string& - replace(size_type tpos, size_type tn, shallow_type sh) - { - return this->replace(tpos, tn, sh.data(), sh.size()); - } - - basic_cow_string& - replace(size_type tpos, shallow_type sh) - { - return this->replace(tpos, npos, sh); - } - - basic_cow_string& - replace(size_type tpos, size_type tn, initializer_list init) - { - return this->replace(tpos, tn, init.begin(), init.size()); - } - - basic_cow_string& - replace(size_type tpos, initializer_list init) - { - return this->replace(tpos, npos, init); - } - basic_cow_string& replace(size_type tpos, size_type tn, const basic_cow_string& other, size_type pos = 0, size_type n = npos) { @@ -917,18 +845,6 @@ class basic_cow_string return this->replace(tpos, npos, move(first), move(last)); } - iterator - replace(const_iterator tfirst, const_iterator tlast, shallow_type sh) - { - return this->replace(tfirst, tlast, sh.data(), sh.size()); - } - - iterator - replace(const_iterator tfirst, const_iterator tlast, initializer_list init) - { - return this->replace(tfirst, tlast, init.begin(), init.size()); - } - iterator replace(const_iterator tfirst, const_iterator tlast, const basic_cow_string& other, size_type pos = 0, size_type n = npos) { @@ -979,18 +895,6 @@ class basic_cow_string return iterator(tptr - tpos, tpos, this->size()); } - basic_cow_string& - insert(size_type tpos, shallow_type sh) - { - return this->replace(tpos, size_type(0), sh); - } - - basic_cow_string& - insert(size_type tpos, initializer_list init) - { - return this->replace(tpos, size_type(0), init); - } - basic_cow_string& insert(size_type tpos, const basic_cow_string& other, size_type pos = 0, size_type n = npos) { @@ -1023,18 +927,6 @@ class basic_cow_string return this->replace(tpos, size_type(0), move(first), move(last)); } - iterator - insert(const_iterator tins, shallow_type sh) - { - return this->replace(tins, tins, sh); - } - - iterator - insert(const_iterator tins, initializer_list init) - { - return this->replace(tins, tins, init); - } - iterator insert(const_iterator tins, const basic_cow_string& other, size_type pos = 0, size_type n = npos) { @@ -1145,20 +1037,6 @@ class basic_cow_string return this->copy(size_type(0), s, tn); } - basic_cow_string& - assign(shallow_type sh) - { - this->replace(this->begin(), this->end(), sh); - return *this; - } - - basic_cow_string& - assign(initializer_list init) - { - this->replace(this->begin(), this->end(), init); - return *this; - } - basic_cow_string& assign(const basic_cow_string& other, size_type pos = 0, size_type n = npos) { @@ -1250,34 +1128,7 @@ class basic_cow_string get_allocator() noexcept { return this->m_sth.as_allocator(); } - constexpr - size_type - find(size_type from, shallow_type sh) const noexcept - { - return this->find(from, sh.data(), sh.size()); - } - - constexpr - size_type - find(shallow_type sh) const noexcept - { - return this->find(size_type(0), sh); - } - - constexpr - size_type - find(size_type from, initializer_list init) const noexcept - { - return this->find(from, init.begin(), init.size()); - } - - constexpr - size_type - find(initializer_list init) const noexcept - { - return this->find(size_type(0), init); - } - + // searching functions constexpr size_type find(size_type from, const basic_cow_string& other) const noexcept @@ -1370,34 +1221,6 @@ class basic_cow_string return this->find(size_type(0), c); } - constexpr - size_type - rfind(size_type to, shallow_type sh) const noexcept - { - return this->rfind(to, sh.data(), sh.size()); - } - - constexpr - size_type - rfind(shallow_type sh) const noexcept - { - return this->rfind(npos, sh); - } - - constexpr - size_type - rfind(size_type to, initializer_list init) const noexcept - { - return this->rfind(to, init.begin(), init.size()); - } - - constexpr - size_type - rfind(initializer_list init) const noexcept - { - return this->rfind(npos, init); - } - constexpr size_type rfind(size_type to, const basic_cow_string& other) const noexcept @@ -1488,34 +1311,6 @@ class basic_cow_string return this->rfind(npos, c); } - constexpr - size_type - find_of(size_type from, shallow_type sh) const noexcept - { - return this->find_of(from, sh.data(), sh.size()); - } - - constexpr - size_type - find_of(shallow_type sh) const noexcept - { - return this->find_of(size_type(0), sh); - } - - constexpr - size_type - find_of(size_type from, initializer_list init) const noexcept - { - return this->find_of(from, init.begin(), init.size()); - } - - constexpr - size_type - find_of(initializer_list init) const noexcept - { - return this->find_of(size_type(0), init); - } - constexpr size_type find_of(size_type from, const basic_cow_string& other) const noexcept @@ -1621,34 +1416,6 @@ class basic_cow_string return this->find_of(size_type(0), c); } - constexpr - size_type - rfind_of(size_type to, shallow_type sh) const noexcept - { - return this->rfind_of(to, sh.data(), sh.size()); - } - - constexpr - size_type - rfind_of(shallow_type sh) const noexcept - { - return this->rfind_of(npos, sh); - } - - constexpr - size_type - rfind_of(size_type to, initializer_list init) const noexcept - { - return this->rfind_of(to, init.begin(), init.size()); - } - - constexpr - size_type - rfind_of(initializer_list init) const noexcept - { - return this->rfind_of(npos, init); - } - constexpr size_type rfind_of(size_type to, const basic_cow_string& other) const noexcept @@ -1752,34 +1519,6 @@ class basic_cow_string return this->rfind_of(npos, c); } - constexpr - size_type - find_not_of(size_type from, shallow_type sh) const noexcept - { - return this->find_not_of(from, sh.data(), sh.size()); - } - - constexpr - size_type - find_not_of(shallow_type sh) const noexcept - { - return this->find_not_of(size_type(0), sh); - } - - constexpr - size_type - find_not_of(size_type from, initializer_list init) const noexcept - { - return this->find_not_of(from, init.begin(), init.size()); - } - - constexpr - size_type - find_not_of(initializer_list init) const noexcept - { - return this->find_not_of(size_type(0), init); - } - constexpr size_type find_not_of(size_type from, const basic_cow_string& other) const noexcept @@ -1883,34 +1622,6 @@ class basic_cow_string return this->find_not_of(size_type(0), c); } - constexpr - size_type - rfind_not_of(size_type to, shallow_type sh) const noexcept - { - return this->rfind_not_of(to, sh.data(), sh.size()); - } - - constexpr - size_type - rfind_not_of(shallow_type sh) const noexcept - { - return this->rfind_not_of(npos, sh); - } - - constexpr - size_type - rfind_not_of(size_type to, initializer_list init) const noexcept - { - return this->rfind_not_of(to, init.begin(), init.size()); - } - - constexpr - size_type - rfind_not_of(initializer_list init) const noexcept - { - return this->rfind_not_of(npos, init); - } - constexpr size_type rfind_not_of(size_type to, const basic_cow_string& other) const noexcept @@ -2014,20 +1725,6 @@ class basic_cow_string return this->rfind_not_of(npos, c); } - constexpr - bool - equals(shallow_type sh) const noexcept - { - return this->equals(sh.data(), sh.size()); - } - - constexpr - bool - equals(initializer_list init) const noexcept - { - return this->equals(init.begin(), init.size()); - } - constexpr bool equals(const basic_cow_string& other) const noexcept @@ -2056,34 +1753,6 @@ class basic_cow_string return (this->size() == n) && noadl::xmemeq(this->data(), s, n); } - constexpr - bool - substr_equals(size_type tpos, size_type tn, shallow_type sh) const - { - return this->substr_equals(tpos, tn, sh.data(), sh.size()); - } - - constexpr - bool - substr_equals(size_type tpos, shallow_type sh) const - { - return this->substr_equals(tpos, npos, sh); - } - - constexpr - bool - substr_equals(size_type tpos, size_type tn, initializer_list init) const - { - return this->substr_equals(tpos, tn, init.begin(), init.size()); - } - - constexpr - bool - substr_equals(size_type tpos, initializer_list init) const - { - return this->substr_equals(tpos, npos, init); - } - constexpr bool substr_equals(size_type tpos, size_type tn, const basic_cow_string& other, size_type pos = 0, size_type n = npos) const @@ -2126,20 +1795,6 @@ class basic_cow_string return this->substr_equals(tpos, npos, s, n); } - constexpr - int - compare(shallow_type sh) const noexcept - { - return this->compare(sh.data(), sh.size()); - } - - constexpr - int - compare(initializer_list init) const noexcept - { - return this->compare(init.begin(), init.size()); - } - constexpr int compare(const basic_cow_string& other) const noexcept @@ -2168,34 +1823,6 @@ class basic_cow_string return noadl::xmemcmp(this->data(), this->size(), s, n); } - constexpr - int - substr_compare(size_type tpos, size_type tn, shallow_type sh) const - { - return this->substr_compare(tpos, tn, sh.data(), sh.size()); - } - - constexpr - int - substr_compare(size_type tpos, shallow_type sh) const - { - return this->substr_compare(tpos, npos, sh); - } - - constexpr - int - substr_compare(size_type tpos, size_type tn, initializer_list init) const - { - return this->substr_compare(tpos, tn, init.begin(), init.size()); - } - - constexpr - int - substr_compare(size_type tpos, initializer_list init) const - { - return this->substr_compare(tpos, npos, init); - } - constexpr int substr_compare(size_type tpos, size_type tn, const basic_cow_string& other, size_type pos = 0, size_type n = npos) const @@ -2239,20 +1866,6 @@ class basic_cow_string } // N.B. These are extensions but might be standardized in C++20. - constexpr - bool - starts_with(shallow_type sh) const noexcept - { - return this->starts_with(sh.data(), sh.size()); - } - - constexpr - bool - starts_with(initializer_list init) const noexcept - { - return this->starts_with(init.begin(), init.size()); - } - constexpr bool starts_with(const basic_cow_string& other) const noexcept @@ -2281,20 +1894,6 @@ class basic_cow_string return (this->size() >= n) && noadl::xmemeq(this->data(), s, n); } - constexpr - bool - ends_with(shallow_type sh) const noexcept - { - return this->ends_with(sh.data(), sh.size()); - } - - constexpr - bool - ends_with(initializer_list init) const noexcept - { - return this->ends_with(init.begin(), init.size()); - } - constexpr bool ends_with(const basic_cow_string& other) const noexcept @@ -2362,11 +1961,6 @@ struct basic_cow_string::hash uint32_t operator()(const shallow_type& sh) const noexcept { return this->do_hash_bytes(sh.m_ptr, sh.m_len); } - - constexpr ROCKET_ALWAYS_INLINE // https://gcc.gnu.org/PR109464 - uint32_t - operator()(const value_type* s) const noexcept - { return this->do_hash_bytes(s, details_xstring::maybe_constexpr::ystrlen(s)); } }; template