diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 22:14:11 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 22:14:11 +0000 |
commit | fecec563479589b3649b1283f8b7d0662704f12b (patch) | |
tree | 4c391b6b9dbb886644de5ad7f9aa2f5941508779 /chrome/common/notification_details.h | |
parent | d8ab621fc2ed73e4e23ad534a3b896f269b66ac6 (diff) | |
download | chromium_src-fecec563479589b3649b1283f8b7d0662704f12b.zip chromium_src-fecec563479589b3649b1283f8b7d0662704f12b.tar.gz chromium_src-fecec563479589b3649b1283f8b7d0662704f12b.tar.bz2 |
Allow Source<T> and Details<T> to be instantiated with T = const Foo.
Review URL: http://codereview.chromium.org/118185
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17550 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/notification_details.h')
-rw-r--r-- | chrome/common/notification_details.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/chrome/common/notification_details.h b/chrome/common/notification_details.h index c938542..ee10111 100644 --- a/chrome/common/notification_details.h +++ b/chrome/common/notification_details.h @@ -33,9 +33,11 @@ class NotificationDetails { } protected: - NotificationDetails(void* ptr) : ptr_(ptr) {} + NotificationDetails(const void* ptr) : ptr_(ptr) {} - void* ptr_; + // Declaring this const allows Details<T> to be used with both T = Foo and + // T = const Foo. + const void* ptr_; }; template <class T> @@ -46,7 +48,8 @@ class Details : public NotificationDetails { : NotificationDetails(other) {} T* operator->() const { return ptr(); } - T* ptr() const { return static_cast<T*>(ptr_); } + // The casts here allow this to compile with both T = Foo and T = const Foo. + T* ptr() const { return static_cast<T*>(const_cast<void*>(ptr_)); } }; #endif // CHROME_COMMON_NOTIFICATION_DETAILS_H__ |