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

Side by Side Diff: Source/wtf/PassRefPtr.h

Issue 802203004: replace COMPILE_ASSERT with static assert in wtf/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: final fixups Created 6 years 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/wtf/PassOwnPtr.h ('k') | Source/wtf/SizeLimits.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 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reser ved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reser ved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // This conversion operator allows implicit conversion to bool but not t o other integer types. 86 // This conversion operator allows implicit conversion to bool but not t o other integer types.
87 typedef T* (PassRefPtr::*UnspecifiedBoolType); 87 typedef T* (PassRefPtr::*UnspecifiedBoolType);
88 operator UnspecifiedBoolType() const { return m_ptr ? &PassRefPtr::m_ptr : 0; } 88 operator UnspecifiedBoolType() const { return m_ptr ? &PassRefPtr::m_ptr : 0; }
89 89
90 friend PassRefPtr adoptRef<T>(T*); 90 friend PassRefPtr adoptRef<T>(T*);
91 91
92 private: 92 private:
93 enum AdoptRefTag { AdoptRef }; 93 enum AdoptRefTag { AdoptRef };
94 PassRefPtr(T* ptr, AdoptRefTag) : m_ptr(ptr) { } 94 PassRefPtr(T* ptr, AdoptRefTag) : m_ptr(ptr) { }
95 95
96 PassRefPtr& operator=(const PassRefPtr&) { COMPILE_ASSERT(!sizeof(T*), P assRefPtr_should_never_be_assigned_to); return *this; } 96 PassRefPtr& operator=(const PassRefPtr&) { static_assert(!sizeof(T*), "P assRefPtr should never be assigned to"); return *this; }
97 97
98 mutable T* m_ptr; 98 mutable T* m_ptr;
99 }; 99 };
100 100
101 template<typename T> template<typename U> inline PassRefPtr<T>::PassRefPtr(c onst RefPtr<U>& o, EnsurePtrConvertibleArgDefn(U, T)) 101 template<typename T> template<typename U> inline PassRefPtr<T>::PassRefPtr(c onst RefPtr<U>& o, EnsurePtrConvertibleArgDefn(U, T))
102 : m_ptr(o.get()) 102 : m_ptr(o.get())
103 { 103 {
104 T* ptr = m_ptr; 104 T* ptr = m_ptr;
105 refIfNotNull(ptr); 105 refIfNotNull(ptr);
106 } 106 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return p.get(); 198 return p.get();
199 } 199 }
200 200
201 } // namespace WTF 201 } // namespace WTF
202 202
203 using WTF::PassRefPtr; 203 using WTF::PassRefPtr;
204 using WTF::adoptRef; 204 using WTF::adoptRef;
205 using WTF::static_pointer_cast; 205 using WTF::static_pointer_cast;
206 206
207 #endif // WTF_PassRefPtr_h 207 #endif // WTF_PassRefPtr_h
OLDNEW
« no previous file with comments | « Source/wtf/PassOwnPtr.h ('k') | Source/wtf/SizeLimits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698