llvm.org GIT mirror
Properly convert some &'s to &amp;'s git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5868 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
1 changed file(s) with 16 addition(s) and 16 deletion(s).
 377 377 public std::iterator { 378 378 friend class container; 379 379 public: 380 const value_type& operator*() const;⏎ 380 const value_type& operator*() const;⏎ 381 381 const value_type* operator->() const; 382 const_iterator& operator++();⏎ 382 const_iterator& operator++();⏎ 383 383 const_iterator operator++(int); 384 384 friend bool operator==(const_iterator lhs, 385 385 const_iterator rhs); 407 407 There are normally only three member functions that need nontrivial 408 408 implementations; the rest are just boilerplate. 409 409 410 const container::value_type&⏎ 410 const container::value_type&⏎ 411 411 container::const_iterator::operator*() const { 412 412 // find the element and return a reference to it 413 413 } 414 414 415 415 const container::value_type* 416 416 container::const_iterator::operator->() const { 417 return &**this;⏎ 417 return &**this;⏎ 418 418 } 419 419 420 420 If there's an underlying real container, operator*() can just return a 430 430 The operator->() function is just boilerplate around a call to 431 431 operator*(). 432 432 433 container::const_iterator&⏎ 433 container::const_iterator&⏎ 434 434 container::const_iterator::operator++() { 435 435 // the incrementing logic goes here 436 436 return *this; 490 490 friend class container; 491 491 friend class container::const_iterator; 492 492 public: 493 value_type& operator*() const;⏎ 493 value_type& operator*() const;⏎ 494 494 value_type* operator->() const; 495 iterator& operator++();⏎ 495 iterator& operator++();⏎ 496 496 iterator operator++(int); 497 497 friend bool operator==(iterator lhs, iterator rhs); 498 498 friend bool operator!=(iterator lhs, iterator rhs); 504 504 friend class container; 505 505 public: 506 506 const_iterator(); 507 const_iterator(const iterator& i); 508 const value_type& operator*() const;⏎ 507 const_iterator(const iterator& i);⏎ 508 const value_type& operator*() const; 509 509 const value_type* operator->() const; 510 const_iterator& operator++();⏎ 510 const_iterator& operator++();⏎ 511 511 const_iterator operator++(int); 512 512 friend bool operator==(const_iterator lhs, 513 513 const_iterator rhs); 536 536 public std::iterator { 537 537 public: 538 538 //... 539 iterator& operator--();⏎ 539 iterator& operator--();⏎ 540 540 iterator operator--(int); 541 541 //... 542 542 }; 550 550 public std::iterator { 551 551 public: 552 552 //... 553 iterator& operator+=(difference_type rhs); 554 iterator& operator-=(difference_type rhs);⏎ 553 iterator& operator+=(difference_type rhs);⏎ 554 iterator& operator-=(difference_type rhs); 555 555 friend iterator operator+(iterator lhs, difference_type rhs); 556 556 friend iterator operator+(difference_type lhs, iterator rhs); 557 557 friend iterator operator-(iterator lhs, difference_type rhs); 563 563 //... 564 564 }; 565 565 566 container::iterator&⏎ 566 container::iterator&⏎ 567 567 container::iterator::operator+=(container::difference_type rhs) { 568 568 // add rhs to iterator position 569 569 return *this; 570 570 } 571 571 572 container::iterator&⏎ 572 container::iterator&⏎ 573 573 container::iterator::operator-=(container::difference_type rhs) { 574 574 // subtract rhs from iterator position 575 575 return *this; 659 659 660 660 661 661 662 Last modified: Sun Jan 20 13:01:02 CST 2002⏎ 662 Last modified: Wed Apr 23 11:20:49 CDT 2003⏎ 663 663 664 664 665 665