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

Side by Side Diff: source/common/cmemory.h

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 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
« no previous file with comments | « source/common/charstr.cpp ('k') | source/common/common.vcxproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ****************************************************************************** 2 ******************************************************************************
3 * 3 *
4 * Copyright (C) 1997-2015, International Business Machines 4 * Copyright (C) 1997-2015, International Business Machines
5 * Corporation and others. All Rights Reserved. 5 * Corporation and others. All Rights Reserved.
6 * 6 *
7 ****************************************************************************** 7 ******************************************************************************
8 * 8 *
9 * File CMEMORY.H 9 * File CMEMORY.H
10 * 10 *
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 * @see LocalPointerBase 151 * @see LocalPointerBase
152 */ 152 */
153 template<typename T> 153 template<typename T>
154 class LocalMemory : public LocalPointerBase<T> { 154 class LocalMemory : public LocalPointerBase<T> {
155 public: 155 public:
156 /** 156 /**
157 * Constructor takes ownership. 157 * Constructor takes ownership.
158 * @param p simple pointer to an array of T items that is adopted 158 * @param p simple pointer to an array of T items that is adopted
159 */ 159 */
160 explicit LocalMemory(T *p=NULL) : LocalPointerBase<T>(p) {} 160 explicit LocalMemory(T *p=NULL) : LocalPointerBase<T>(p) {}
161 #if U_HAVE_RVALUE_REFERENCES
162 /**
163 * Move constructor, leaves src with isNull().
164 * @param src source smart pointer
165 */
166 LocalMemory(LocalMemory<T> &&src) U_NOEXCEPT : LocalPointerBase<T>(src.ptr) {
167 src.ptr=NULL;
168 }
169 #endif
161 /** 170 /**
162 * Destructor deletes the memory it owns. 171 * Destructor deletes the memory it owns.
163 */ 172 */
164 ~LocalMemory() { 173 ~LocalMemory() {
165 uprv_free(LocalPointerBase<T>::ptr); 174 uprv_free(LocalPointerBase<T>::ptr);
166 } 175 }
176 #if U_HAVE_RVALUE_REFERENCES
177 /**
178 * Move assignment operator, leaves src with isNull().
179 * The behavior is undefined if *this and src are the same object.
180 * @param src source smart pointer
181 * @return *this
182 */
183 LocalMemory<T> &operator=(LocalMemory<T> &&src) U_NOEXCEPT {
184 return moveFrom(src);
185 }
186 #endif
187 /**
188 * Move assignment, leaves src with isNull().
189 * The behavior is undefined if *this and src are the same object.
190 *
191 * Can be called explicitly, does not need C++11 support.
192 * @param src source smart pointer
193 * @return *this
194 */
195 LocalMemory<T> &moveFrom(LocalMemory<T> &src) U_NOEXCEPT {
196 delete[] LocalPointerBase<T>::ptr;
197 LocalPointerBase<T>::ptr=src.ptr;
198 src.ptr=NULL;
199 return *this;
200 }
201 /**
202 * Swap pointers.
203 * @param other other smart pointer
204 */
205 void swap(LocalMemory<T> &other) U_NOEXCEPT {
206 T *temp=LocalPointerBase<T>::ptr;
207 LocalPointerBase<T>::ptr=other.ptr;
208 other.ptr=temp;
209 }
210 /**
211 * Non-member LocalMemory swap function.
212 * @param p1 will get p2's pointer
213 * @param p2 will get p1's pointer
214 */
215 friend inline void swap(LocalMemory<T> &p1, LocalMemory<T> &p2) U_NOEXCEPT {
216 p1.swap(p2);
217 }
167 /** 218 /**
168 * Deletes the array it owns, 219 * Deletes the array it owns,
169 * and adopts (takes ownership of) the one passed in. 220 * and adopts (takes ownership of) the one passed in.
170 * @param p simple pointer to an array of T items that is adopted 221 * @param p simple pointer to an array of T items that is adopted
171 */ 222 */
172 void adoptInstead(T *p) { 223 void adoptInstead(T *p) {
173 uprv_free(LocalPointerBase<T>::ptr); 224 uprv_free(LocalPointerBase<T>::ptr);
174 LocalPointerBase<T>::ptr=p; 225 LocalPointerBase<T>::ptr=p;
175 } 226 }
176 /** 227 /**
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 ptr=&stackHeader; 642 ptr=&stackHeader;
592 capacity=stackCapacity; 643 capacity=stackCapacity;
593 needToRelease=FALSE; 644 needToRelease=FALSE;
594 return p; 645 return p;
595 } 646 }
596 647
597 U_NAMESPACE_END 648 U_NAMESPACE_END
598 649
599 #endif /* __cplusplus */ 650 #endif /* __cplusplus */
600 #endif /* CMEMORY_H */ 651 #endif /* CMEMORY_H */
OLDNEW
« no previous file with comments | « source/common/charstr.cpp ('k') | source/common/common.vcxproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698