Changeset dc0fff11 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:
- 9315761
- Parents:
- c20cccb
- git-author:
- Jaroslav Jindrak <dzejrou@…> (2017-10-30 12:49:17)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:18)
- Location:
- uspace/lib/cpp/include/impl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/iosfwd.hpp
rc20cccb rdc0fff11 82 82 template<class Char, class Traits = char_traits<Char>, 83 83 class Allocator = allocator<Char>> 84 class basic_ istringstream;84 class basic_ostringstream; 85 85 86 86 template<class Char, class Traits = char_traits<Char>, 87 87 class Allocator = allocator<Char>> 88 class basic_ istringstream;88 class basic_stringstream; 89 89 90 90 … … 147 147 148 148 // TODO: standard p. 1012, this is circular, it offers fix 149 using streampos = fpos<char_traits<char>::state_type>; 150 using wstreampos = fpos<char_traits<wchar_t>::state_type>; 149 /* using streampos = fpos<char_traits<char>::state_type>; */ 150 /* using wstreampos = fpos<char_traits<wchar_t>::state_type>; */ 151 // Temporary workaround. 152 using streampos = unsigned long long; 153 using wstreampos = unsigned long long; 154 // TODO: This should be in ios and not here? 155 using streamoff = long long; 151 156 } -
uspace/lib/cpp/include/impl/memory.hpp
rc20cccb rdc0fff11 31 31 32 32 #include <internal/aux.hpp> 33 #include <utility> 33 34 #include <type_traits> 34 35 -
uspace/lib/cpp/include/impl/string.hpp
rc20cccb rdc0fff11 30 30 #define LIBCPP_STRING 31 31 32 #include < initializer_list>32 #include <algorithm> 33 33 #include <iosfwd> 34 #include <iterator> 34 35 #include <cstdio> 35 36 #include <cstdlib> 36 37 #include <cstring> 38 #include <memory> 39 #include <utility> 40 41 #include <initializer_list> 37 42 38 43 namespace std … … 179 184 static int compare(const char_type* s1, const char_type* s2, size_t n) 180 185 { 181 return std::wstr_lcmp(s1, s2, n); 186 // TODO: This function does not exits... 187 //return std::wstr_lcmp(s1, s2, n); 188 return 0; 182 189 } 183 190 … … 260 267 using reference = value_type&; 261 268 using const_reference = const value_type&; 262 using pointer = allocator_traits<allocator_type>::pointer;263 using const_pointer = allocator_traits<allocator_type>::const_pointer;269 using pointer = typename allocator_traits<allocator_type>::pointer; 270 using const_pointer = typename allocator_traits<allocator_type>::const_pointer; 264 271 265 272 using iterator = pointer; … … 286 293 * capacity() = unspecified 287 294 */ 288 data_ = allocator_.allocate( initial_capacity_);289 capacity_ = initial_capacity_;295 data_ = allocator_.allocate(default_capacity_); 296 capacity_ = default_capacity_; 290 297 } 291 298 … … 315 322 } 316 323 317 basic_string(const value_type* str, size_type n, const allocator_type& alloc = allocator {})324 basic_string(const value_type* str, size_type n, const allocator_type& alloc = allocator_type{}) 318 325 : data_{}, size_{n}, capacity_{n}, allocator_{alloc} 319 326 { … … 321 328 } 322 329 323 basic_string(const value_type* str, const allocator_type& alloc = allocator {})330 basic_string(const value_type* str, const allocator_type& alloc = allocator_type{}) 324 331 : data_{}, size_{}, capacity_{}, allocator_{alloc} 325 332 { … … 327 334 } 328 335 329 basic_string(size_type n, value_type c, const allocator_type& alloc = allocator {})336 basic_string(size_type n, value_type c, const allocator_type& alloc = allocator_type{}) 330 337 : data_{}, size_{n}, capacity_{n}, allocator_{alloc} 331 338 { … … 338 345 template<class InputIterator> 339 346 basic_string(InputIterator first, InputIterator last, 340 const allocator_type& alloc = allocator {})347 const allocator_type& alloc = allocator_type{}) 341 348 : data_{}, size_{}, capacity_{}, allocator_{alloc} 342 349 { 343 if constexpr (is_integral _t<InputIterator>)350 if constexpr (is_integral<InputIterator>::value) 344 351 { // Required by the standard. 345 352 size_ = static_cast<size_type>(first); … … 358 365 } 359 366 360 basic_string(initializer_list<value_type> init, const allocator_type& alloc = allocator {})367 basic_string(initializer_list<value_type> init, const allocator_type& alloc = allocator_type{}) 361 368 : basic_string{init.begin(), init.size(), alloc} 362 369 { /* DUMMY BODY */ } … … 629 636 } 630 637 631 basic_string& append(const basic_string& str, size_type pos 638 basic_string& append(const basic_string& str, size_type pos, 632 639 size_type n = npos) 633 640 { … … 666 673 basic_string& append(InputIterator first, InputIterator last) 667 674 { 668 return append(basic_string(f rist, last));675 return append(basic_string(first, last)); 669 676 } 670 677 … … 704 711 } 705 712 // TODO: Else throw out_of_range. 713 714 return *this; 706 715 } 707 716 … … 711 720 resize_without_copy_(n); 712 721 traits_type::copy(begin(), str, n); 722 size_ = n; 723 ensure_null_terminator_(); 713 724 714 725 return *this; … … 792 803 copy_backward_(begin() + pos, end(), end() + n); 793 804 794 auto it = pos ition;805 auto it = pos; 795 806 for (size_type i = 0; i < n; ++i) 796 t ype_traits::assign(*it++, c);807 traits_type::assign(*it++, c); 797 808 ensure_null_terminator_(); 798 809 … … 812 823 } 813 824 814 basic_string& erase(size_type pos = 0 ;size_type n = npos)825 basic_string& erase(size_type pos = 0, size_type n = npos) 815 826 { 816 827 auto len = min(n, size_ - pos); … … 825 836 { 826 837 auto idx = static_cast<size_type>(pos - cbegin()); 827 erase( dx, 1);838 erase(idx, 1); 828 839 829 840 return begin() + idx; … … 851 862 } 852 863 853 basic_string& replace(size_type pos1, size_type n1, const basic_string& str 864 basic_string& replace(size_type pos1, size_type n1, const basic_string& str, 854 865 size_type pos2, size_type n2 = npos) 855 866 { … … 895 906 const value_type* str, size_type n) 896 907 { 897 return replace(i1 - begin(), i2 - i1, s , n);908 return replace(i1 - begin(), i2 - i1, str, n); 898 909 } 899 910 … … 1256 1267 * set capacity to 0, but that would be too cryptic.) 1257 1268 */ 1258 static constexpr size_type default_capacity_{4} 1269 static constexpr size_type default_capacity_{4}; 1259 1270 1260 1271 void init_(const value_type* str, size_type size) … … 1286 1297 * reserve can cause shrinking. 1287 1298 */ 1288 if (size_ + 1 + n > capacity )1299 if (size_ + 1 + n > capacity_) 1289 1300 resize_with_copy_(size_, max(size_ + 1 + n, next_capacity_())); 1290 1301 } … … 1342 1353 void ensure_null_terminator_() 1343 1354 { 1344 traits_type::assign(data_[size_], value_type{}); 1355 value_type c{}; 1356 traits_type::assign(data_[size_], c); 1345 1357 } 1346 1358 … … 1369 1381 } 1370 1382 }; 1383 1384 using string = basic_string<char>; 1371 1385 } 1372 1386 -
uspace/lib/cpp/include/impl/type_traits.hpp
rc20cccb rdc0fff11 153 153 { /* DUMMY BODY */ }; 154 154 155 template<class T> 156 struct is_integral: __is_integral< remove_cv_t<T>>155 template<class T> // TODO: use remove_cv when implemented 156 struct is_integral: __is_integral<T> 157 157 { /* DUMMY BODY */ }; 158 158
Note:
See TracChangeset
for help on using the changeset viewer.