From 89621addb4a7c87d2e3f3e7462e3c690cf71de71 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Wed, 16 Mar 2016 21:31:24 +0100 Subject: 7.6 --- zen/fixed_list.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'zen/fixed_list.h') 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 #include + 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 - Node(Args&& ... args) : next(nullptr), val(std::forward(args)...) {} + Node(Args&& ... args) : val(std::forward(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 { 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 -- cgit