Changeset b0b46d59 in mainline
- Timestamp:
- 2018-07-05T21:41:18Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e07bbbc
- Parents:
- 681fdcca
- git-author:
- Jaroslav Jindrak <dzejrou@…> (2017-10-27 19:26:11)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:18)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/string.hpp
r681fdcca rb0b46d59 830 830 } 831 831 832 basic_string& replace(size_type pos, size_type n, const basic_string& str); 832 basic_string& replace(size_type pos, size_type n, const basic_string& str) 833 { 834 // TODO: throw out_of_range if pos > size() 835 return replace(pos, n, str.data(), str.size()); 836 } 833 837 834 838 basic_string& replace(size_type pos1, size_type n1, const basic_string& str 835 size_type pos2, size_type n2); 839 size_type pos2, size_type n2 = npos) 840 { 841 // TODO: throw out_of_range if pos1 > size() or pos2 > str.size() 842 auto len = min(n2, str.size() - pos2); 843 return replace(pos1, n1, str.data() + pos2, len); 844 } 836 845 837 846 basic_string& replace(size_type pos, size_type n1, const value_type* str, 838 size_type n2); 839 840 basic_string& replace(size_type pos, size_type n, const value_type* str); 847 size_type n2) 848 { 849 // TODO: format and comment this properly 850 // TODO: throw out_of_range if pos > size() 851 auto len = min(n1, size_ - pos); 852 // TODO: if size() - len > max_size() - n2 throw length_error 853 basic_string tmp{}; 854 tmp.resize_without_copy_(size_ - len + n2); 855 copy_(begin(), begin() + pos, tmp.begin()); 856 traits_type::copy(tmp.begin() + pos + 1, str, n2); 857 copy_(begin() + pos + len, end(), tmp.begin() + pos + 1 + n2); 858 swap(tmp); 859 return *this; 860 } 861 862 basic_string& replace(size_type pos, size_type n, const value_type* str) 863 { 864 return replace(pos, n, str, traits_type::length(str)); 865 } 841 866 842 867 basic_string& replace(size_type pos, size_type n1, size_type n2, 843 value_type c); 868 value_type c) 869 { 870 return replace(pos, n1, basic_string(n2, c)); 871 } 844 872 845 873 basic_string& replace(const_iterator i1, const_iterator i2, 846 const basic_string& str); 874 const basic_string& str) 875 { 876 return replace(i1 - begin(), i2 - i1, str); 877 } 847 878 848 879 basic_string& replace(const_iterator i1, const_iterator i2, 849 const value_type* str, size_type n); 880 const value_type* str, size_type n) 881 { 882 return replace(i1 - begin(), i2 - i1, s, n); 883 } 850 884 851 885 basic_string& replace(const_iterator i1, const_iterator i2, 852 const value_type* str); 886 const value_type* str) 887 { 888 return replace(i1 - begin(), i2 - i1, str, traits_type::length(str)); 889 } 853 890 854 891 basic_string& replace(const_iterator i1, const_iterator i2, 855 value_type c); 892 size_type n, value_type c) 893 { 894 return replace(i1 - begin(), i2 - i1, basic_string(n, c)); 895 } 856 896 857 897 template<class InputIterator> 858 898 basic_string& replace(const_iterator i1, const_iterator i2, 859 InputIterator j1, InputIterator j2); 899 InputIterator j1, InputIterator j2) 900 { 901 return replace(i1 - begin(), i2 - i1, basic_string(j1, j2)); 902 } 860 903 861 904 basic_string& replace(const_iterator i1, const_iterator i2, 862 initializer_list<value_type> init); 905 initializer_list<value_type> init) 906 { 907 return replace(i1 - begin(), i2 - i1, init.begin(), init.size()); 908 } 863 909 864 910 size_type copy(value_type* str, size_type n, size_type pos = 0) const;
Note:
See TracChangeset
for help on using the changeset viewer.