diff options
author | Daniel Wilhelm <daniel@wili.li> | 2016-03-16 21:31:24 +0100 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2016-03-16 21:31:24 +0100 |
commit | 89621addb4a7c87d2e3f3e7462e3c690cf71de71 (patch) | |
tree | 008b5dea7624ee1eeb57ff82c45fdf1afcab3b08 /zen/fixed_list.h | |
parent | 7.5 (diff) | |
download | FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.tar.gz FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.tar.bz2 FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.zip |
7.6
Diffstat (limited to 'zen/fixed_list.h')
-rw-r--r-- | zen/fixed_list.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/zen/fixed_list.h b/zen/fixed_list.h index 61ce3f16..362577d5 100644 --- a/zen/fixed_list.h +++ b/zen/fixed_list.h @@ -4,12 +4,13 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef FIXED_LIST_01238467085684139453534 -#define FIXED_LIST_01238467085684139453534 +#ifndef FIXED_LIST_H_01238467085684139453534 +#define FIXED_LIST_H_01238467085684139453534 #include <cassert> #include <iterator> + namespace zen { //std::list(C++11)-like class for inplace element construction supporting non-copyable/movable types @@ -20,9 +21,9 @@ class FixedList struct Node { template <class... Args> - Node(Args&& ... args) : next(nullptr), val(std::forward<Args>(args)...) {} + Node(Args&& ... args) : val(std::forward<Args>(args)...) {} - Node* next; //singly linked list is sufficient + Node* next = nullptr; //singly linked list is sufficient T val; }; @@ -35,14 +36,14 @@ public: class ListIterator : public std::iterator<std::forward_iterator_tag, U> { public: - ListIterator(NodeT* it = nullptr) : iter(it) {} - ListIterator& operator++() { iter = iter->next; return *this; } - inline friend bool operator==(const ListIterator& lhs, const ListIterator& rhs) { return lhs.iter == rhs.iter; } + ListIterator(NodeT* it = nullptr) : it_(it) {} + ListIterator& operator++() { it_ = it_->next; return *this; } + inline friend bool operator==(const ListIterator& lhs, const ListIterator& rhs) { return lhs.it_ == rhs.it_; } inline friend bool operator!=(const ListIterator& lhs, const ListIterator& rhs) { return !(lhs == rhs); } - U& operator* () const { return iter->val; } - U* operator->() const { return &iter->val; } + U& operator* () const { return it_->val; } + U* operator->() const { return &it_->val; } private: - NodeT* iter; + NodeT* it_; }; typedef T value_type; @@ -154,4 +155,4 @@ private: }; } -#endif //FIXED_LIST_01238467085684139453534 +#endif //FIXED_LIST_H_01238467085684139453534 |