Changeset c06328da in mainline
- Timestamp:
- 2018-07-05T21:41:20Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d93f01a6
- Parents:
- bfa86e5
- git-author:
- Dzejrou <dzejrou@…> (2018-04-07 15:00:56)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:20)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/vector.hpp
rbfa86e5 rc06328da 1 1 /* 2 * Copyright (c) 201 7Jaroslav Jindrak2 * Copyright (c) 2018 Jaroslav Jindrak 3 3 * All rights reserved. 4 4 * … … 153 153 allocator_traits<Allocator>::is_always_equal::value) 154 154 { 155 // TODO: implement 155 if (data_) 156 allocator_.deallocate(data_, capacity_); 157 158 // TODO: test this 159 data_ = other.data_; 160 size_ = other.size_; 161 capacity_ = other.capacity_; 162 allocator_ = move(other.allocator_); 163 164 other.data_ = nullptr; 165 other.size_ = size_type{}; 166 other.capacity_ = size_type{}; 167 other.allocator_ = allocator_type{}; 156 168 return *this; 157 169 } … … 370 382 } 371 383 372 // TODO: assert CopyInstertable etc with enable_if!373 384 void push_back(const T& x) 374 385 { … … 584 595 bool operator==(const vector<T, Alloc>& lhs, const vector<T, Alloc>& rhs) 585 596 { 586 // TODO: implement 587 return false; 597 if (lhs.size() != rhs.size()) 598 return false; 599 600 for (decltype(lhs.size()) i = 0; i < lhs.size(); ++i) 601 { 602 if (lhs[i] != rhs[i]) 603 return false; 604 } 605 606 return true; 588 607 } 589 608 … … 591 610 bool operator<(const vector<T, Alloc>& lhs, const vector<T, Alloc>& rhs) 592 611 { 593 // TODO: implement 594 return false; 612 auto min_size = min(lhs.size(), rhs.size()); 613 for (decltype(lhs.size()) i = 0; i < min_size; ++i) 614 { 615 if (lhs[i] >= rhs[i]) 616 return false; 617 } 618 619 if (lhs.size() == rhs.size()) 620 return true; 621 else 622 return lhs.size() < rhs.size(); 595 623 } 596 624 … … 604 632 bool operator>(const vector<T, Alloc>& lhs, const vector<T, Alloc>& rhs) 605 633 { 606 // TODO: implement 607 return false; 634 return rhs < lhs; 608 635 } 609 636 … … 611 638 bool operator>=(const vector<T, Alloc>& lhs, const vector<T, Alloc>& rhs) 612 639 { 613 // TODO: implement 614 return false; 640 return !(lhs < rhs); 615 641 } 616 642 … … 618 644 bool operator<=(const vector<T, Alloc>& lhs, const vector<T, Alloc>& rhs) 619 645 { 620 // TODO: implement 621 return false; 646 return !(rhs < lhs); 622 647 } 623 648 … … 631 656 lhs.swap(rhs); 632 657 } 658 659 /** 660 * 23.3.7, class vector<bool>: 661 */ 662 663 // TODO: implement 633 664 } 634 665
Note:
See TracChangeset
for help on using the changeset viewer.