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

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

Issue 506963002: SkAutoTDelete::operator T*() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 | tests/WArrayTest.cpp » ('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 * 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 guarantees of T. 108 guarantees of T.
109 109
110 The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*) 110 The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*)
111 */ 111 */
112 template <typename T> class SkAutoTDelete : SkNoncopyable { 112 template <typename T> class SkAutoTDelete : SkNoncopyable {
113 public: 113 public:
114 SkAutoTDelete(T* obj = NULL) : fObj(obj) {} 114 SkAutoTDelete(T* obj = NULL) : fObj(obj) {}
115 ~SkAutoTDelete() { SkDELETE(fObj); } 115 ~SkAutoTDelete() { SkDELETE(fObj); }
116 116
117 T* get() const { return fObj; } 117 T* get() const { return fObj; }
118 operator T*() { return fObj; }
118 T& operator*() const { SkASSERT(fObj); return *fObj; } 119 T& operator*() const { SkASSERT(fObj); return *fObj; }
119 T* operator->() const { SkASSERT(fObj); return fObj; } 120 T* operator->() const { SkASSERT(fObj); return fObj; }
120 121
121 void reset(T* obj) { 122 void reset(T* obj) {
122 if (fObj != obj) { 123 if (fObj != obj) {
123 SkDELETE(fObj); 124 SkDELETE(fObj);
124 fObj = obj; 125 fObj = obj;
125 } 126 }
126 } 127 }
127 128
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 /** 471 /**
471 * Returns void* because this object does not initialize the 472 * Returns void* because this object does not initialize the
472 * memory. Use placement new for types that require a cons. 473 * memory. Use placement new for types that require a cons.
473 */ 474 */
474 void* get() { return fStorage.get(); } 475 void* get() { return fStorage.get(); }
475 private: 476 private:
476 SkAlignedSStorage<sizeof(T)*N> fStorage; 477 SkAlignedSStorage<sizeof(T)*N> fStorage;
477 }; 478 };
478 479
479 #endif 480 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/WArrayTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698