Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: base/linked_list.h

Issue 266020: Use static_cast in LinkNode<T>::value() so that it works with... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/linked_list_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_LINKED_LIST_H_ 5 #ifndef BASE_LINKED_LIST_H_
6 #define BASE_LINKED_LIST_H_ 6 #define BASE_LINKED_LIST_H_
7 7
8 // Simple LinkedList type. (See the Q&A section to understand how this 8 // Simple LinkedList type. (See the Q&A section to understand how this
9 // differs from std::list). 9 // differs from std::list).
10 // 10 //
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 LinkNode<T>* previous() const { 111 LinkNode<T>* previous() const {
112 return previous_; 112 return previous_;
113 } 113 }
114 114
115 LinkNode<T>* next() const { 115 LinkNode<T>* next() const {
116 return next_; 116 return next_;
117 } 117 }
118 118
119 // Cast from the node-type to the value type. 119 // Cast from the node-type to the value type.
120 const T* value() const { 120 const T* value() const {
121 return reinterpret_cast<const T*>(this); 121 return static_cast<const T*>(this);
122 } 122 }
123 123
124 T* value() { 124 T* value() {
125 return reinterpret_cast<T*>(this); 125 return static_cast<T*>(this);
126 } 126 }
127 127
128 private: 128 private:
129 LinkNode<T>* previous_; 129 LinkNode<T>* previous_;
130 LinkNode<T>* next_; 130 LinkNode<T>* next_;
131 }; 131 };
132 132
133 template <typename T> 133 template <typename T>
134 class LinkedList { 134 class LinkedList {
135 public: 135 public:
(...skipping 19 matching lines...) Expand all
155 return &root_; 155 return &root_;
156 } 156 }
157 157
158 private: 158 private:
159 LinkNode<T> root_; 159 LinkNode<T> root_;
160 }; 160 };
161 161
162 } // namespace base 162 } // namespace base
163 163
164 #endif // BASE_LINKED_LIST_H_ 164 #endif // BASE_LINKED_LIST_H_
OLDNEW
« no previous file with comments | « no previous file | base/linked_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698