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

Side by Side Diff: include/core/SkTemplates.h

Issue 1114043005: Make SkAutoTDelete's operator T*() const, like all the others. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 7 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 | « no previous file | no next file » | 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 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkTemplates_DEFINED 10 #ifndef SkTemplates_DEFINED
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 guarantees of T. 125 guarantees of T.
126 126
127 The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*) 127 The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*)
128 */ 128 */
129 template <typename T> class SkAutoTDelete : SkNoncopyable { 129 template <typename T> class SkAutoTDelete : SkNoncopyable {
130 public: 130 public:
131 SkAutoTDelete(T* obj = NULL) : fObj(obj) {} 131 SkAutoTDelete(T* obj = NULL) : fObj(obj) {}
132 ~SkAutoTDelete() { SkDELETE(fObj); } 132 ~SkAutoTDelete() { SkDELETE(fObj); }
133 133
134 T* get() const { return fObj; } 134 T* get() const { return fObj; }
135 operator T*() { return fObj; } 135 operator T*() const { return fObj; }
136 T& operator*() const { SkASSERT(fObj); return *fObj; } 136 T& operator*() const { SkASSERT(fObj); return *fObj; }
137 T* operator->() const { SkASSERT(fObj); return fObj; } 137 T* operator->() const { SkASSERT(fObj); return fObj; }
138 138
139 void reset(T* obj) { 139 void reset(T* obj) {
140 if (fObj != obj) { 140 if (fObj != obj) {
141 SkDELETE(fObj); 141 SkDELETE(fObj);
142 fObj = obj; 142 fObj = obj;
143 } 143 }
144 } 144 }
145 145
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 /** 507 /**
508 * Returns void* because this object does not initialize the 508 * Returns void* because this object does not initialize the
509 * memory. Use placement new for types that require a cons. 509 * memory. Use placement new for types that require a cons.
510 */ 510 */
511 void* get() { return fStorage.get(); } 511 void* get() { return fStorage.get(); }
512 private: 512 private:
513 SkAlignedSStorage<sizeof(T)*N> fStorage; 513 SkAlignedSStorage<sizeof(T)*N> fStorage;
514 }; 514 };
515 515
516 #endif 516 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698