Changeset b08a62c 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:
- 79f35d40
- Parents:
- 836ecad
- git-author:
- Jaroslav Jindrak <dzejrou@…> (2017-10-25 21:36:10)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:18)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/string.hpp
r836ecad rb08a62c 320 320 */ 321 321 322 iterator begin() noexcept; 323 324 const_iterator begin() const noexcept; 325 326 iterator end() noexcept; 327 328 const_iterator end() const noexcept; 322 iterator begin() noexcept 323 { 324 return &data_[0]; 325 } 326 327 const_iterator begin() const noexcept 328 { 329 return &data_[0]; 330 } 331 332 iterator end() noexcept 333 { 334 return begin() + size_; 335 } 336 337 const_iterator end() const noexcept 338 { 339 return begin() + size_; 340 } 329 341 330 342 reverse_iterator rbegin() noexcept … … 348 360 } 349 361 350 const_iterator cbegin() const noexcept; 351 352 const_iterator cend() const noexcept; 362 const_iterator cbegin() const noexcept 363 { 364 return &data_[0]; 365 } 366 367 const_iterator cend() const noexcept 368 { 369 return cbegin() + size_; 370 } 353 371 354 372 const_reverse_iterator crbegin() const noexcept … … 366 384 */ 367 385 368 size_type size() const noexcept; 369 370 size_type length() const noexcept; 371 372 size_type max_size() const noexcept; 386 size_type size() const noexcept 387 { 388 return size_; 389 } 390 391 size_type length() const noexcept 392 { 393 return size_; 394 } 395 396 size_type max_size() const noexcept 397 { 398 return allocator_traits<allocator_type>::max_size(allocator_); 399 } 373 400 374 401 void resize(size_type n, value_type c); … … 376 403 void resize(size_type n); 377 404 378 size_type capacity() const noexcept; 405 size_type capacity() const noexcept 406 { 407 return capacity_; 408 } 379 409 380 410 void reserve(size_type res_arg = 0); … … 384 414 void clear() noexcept; 385 415 386 bool empty() const noexcept; 416 bool empty() const noexcept 417 { 418 return size_ == 0; 419 } 387 420 388 421 /** … … 390 423 */ 391 424 392 const_reference operator[](size_type idx) const; 393 394 reference operator[](size_type idx); 395 396 const_reference at(size_type idx) const; 397 398 reference at(size_type idx); 399 400 const_reference front() const; 401 402 reference front(); 403 404 const_reference back() const; 405 406 reference back(); 425 const_reference operator[](size_type idx) const 426 { 427 return data_[idx]; 428 } 429 430 reference operator[](size_type idx) 431 { 432 return data_[idx]; 433 } 434 435 const_reference at(size_type idx) const 436 { 437 // TODO: bounds checking 438 return data_[idx]; 439 } 440 441 reference at(size_type idx) 442 { 443 // TODO: bounds checking 444 return data_[idx]; 445 } 446 447 const_reference front() const 448 { 449 return at(0); 450 } 451 452 reference front() 453 { 454 return at(0); 455 } 456 457 const_reference back() const 458 { 459 return at(size_ - 1); 460 } 461 462 reference back() 463 { 464 return at(size_ - 1); 465 } 407 466 408 467 /** … … 519 578 void swap(basic_string& other) 520 579 noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || 521 allocator_traits<allocator_type>::is_always_equal); 580 allocator_traits<allocator_type>::is_always_equal) 581 { 582 std::swap(data_, other.data_); 583 std::swap(size_, other.size_); 584 std::swap(capacity_, other.capacity_); 585 } 522 586 523 587 /** … … 525 589 */ 526 590 527 const value_type* c_str() const noexcept; 528 529 const value_type* data() const noexcept; 530 531 allocator_type get_allocator() const noexcept; 591 const value_type* c_str() const noexcept 592 { 593 return data_; 594 } 595 596 const value_type* data() const noexcept 597 { 598 return data_; 599 } 600 601 allocator_type get_allocator() const noexcept 602 { 603 return allocator_type{allocator_}; 604 } 532 605 533 606 size_type find(const basic_string& str, size_type pos = 0) const noexcept; … … 594 667 int compare(size_type pos1, size_type n1, 595 668 const value_type* other, size_type n2) const; 669 670 private: 671 value_type* data_; 672 size_type size_; 673 size_type capacity_; 674 allocator_type allocator_; 596 675 }; 597 676 }
Note:
See TracChangeset
for help on using the changeset viewer.