From fe660cdff59aa3a939479ed60172e5c0803552b2 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Sun, 8 Jan 2017 18:21:23 +0100 Subject: 8.7 --- zen/fixed_list.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'zen/fixed_list.h') diff --git a/zen/fixed_list.h b/zen/fixed_list.h index 4376c13f..81197eb4 100644 --- a/zen/fixed_list.h +++ b/zen/fixed_list.h @@ -15,7 +15,7 @@ namespace zen { //std::list(C++11)-like class for inplace element construction supporting non-copyable/non-movable types //-> no iterator invalidation after emplace_back() - + template class FixedList { @@ -69,7 +69,7 @@ public: const_reference& back() const { return lastInsert_->val; } template - void emplace_back(Args&&... args) + void emplace_back(Args&& ... args) { Node* newNode = new Node(std::forward(args)...); @@ -160,10 +160,10 @@ class FixedVector public: FixedVector() {} - /* - class EndIterator {}; //just like FixedList: no iterator invalidation after emplace_back() + /* + class EndIterator {}; //just like FixedList: no iterator invalidation after emplace_back() - template + template class FixedIterator : public std::iterator //could make this random-access if needed { public: @@ -174,10 +174,10 @@ public: V& operator* () const { return *cont_[pos_]; } V* operator->() const { return &*cont_[pos_]; } private: - std::vector>& cont_; - size_t pos_ = 0; + std::vector>& cont_; + size_t pos_ = 0; }; - */ + */ template class FixedIterator : public std::iterator //could make this bidirectional if needed @@ -188,7 +188,7 @@ public: inline friend bool operator==(const FixedIterator& lhs, const FixedIterator& rhs) { return lhs.it_ == rhs.it_; } inline friend bool operator!=(const FixedIterator& lhs, const FixedIterator& rhs) { return !(lhs == rhs); } V& operator* () const { return **it_; } - V* operator->() const { return &**it_; } + V* operator->() const { return &** it_; } private: IterImpl it_; //TODO: avoid iterator invalidation after emplace_back(); caveat: end() must not store old length! }; @@ -199,10 +199,10 @@ public: using reference = T&; using const_reference = const T&; - iterator begin() { return items_.begin(); } + iterator begin() { return items_.begin(); } iterator end () { return items_.end (); } - const_iterator begin() const { return items_.begin(); } + const_iterator begin() const { return items_.begin(); } const_iterator end () const { return items_.end (); } reference front() { return *items_.front(); } @@ -212,15 +212,15 @@ public: const_reference& back() const { return *items_.back(); } template - void emplace_back(Args&&... args) + void emplace_back(Args&& ... args) { - items_.push_back(std::make_unique(std::forward(args)...)); + items_.push_back(std::make_unique(std::forward(args)...)); } template void remove_if(Predicate pred) { - erase_if(items_, [&](const std::unique_ptr& p){ return pred(*p); }); + erase_if(items_, [&](const std::unique_ptr& p) { return pred(*p); }); } void clear() { items_.clear(); } @@ -232,7 +232,7 @@ private: FixedVector (const FixedVector&) = delete; FixedVector& operator=(const FixedVector&) = delete; - std::vector> items_; + std::vector> items_; }; } -- cgit