summaryrefslogtreecommitdiff
path: root/shared/com_ptr.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:09:24 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:09:24 +0200
commitb5f042a6c132c1b97cf03c4615bab966c23f57d2 (patch)
tree1cb057a0ffd51264bb3c9807e2133505ce312eb1 /shared/com_ptr.h
parent3.11 (diff)
downloadFreeFileSync-b5f042a6c132c1b97cf03c4615bab966c23f57d2.tar.gz
FreeFileSync-b5f042a6c132c1b97cf03c4615bab966c23f57d2.tar.bz2
FreeFileSync-b5f042a6c132c1b97cf03c4615bab966c23f57d2.zip
3.12
Diffstat (limited to 'shared/com_ptr.h')
-rw-r--r--shared/com_ptr.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/shared/com_ptr.h b/shared/com_ptr.h
index 1ce7eae6..52a072fa 100644
--- a/shared/com_ptr.h
+++ b/shared/com_ptr.h
@@ -12,7 +12,7 @@
namespace util
{
-/*
+/*
ComPtr: RAII class handling COM objects
Example:
@@ -39,13 +39,20 @@ public:
~ComPtr();
T** init(); //get pointer for use with ::CoCreateInstance()
T* get() const;
- T* release();
+ T* release(); //throw()
void swap(ComPtr& rhs); //throw()
T* operator->() const;
- operator bool() const;
private:
T* ptr;
+
+ struct ConversionToBool
+ {
+ int dummy;
+ };
+
+public:
+ operator int ConversionToBool::*() const; //use member pointer as implicit conversion to bool (C++ Templates - Vandevoorde/Josuttis; chapter 20)
};
@@ -162,12 +169,22 @@ T* ComPtr<T>::operator->() const
}
+/*
template <class T>
inline
ComPtr<T>::operator bool() const
{
return ptr != NULL;
}
+*/
+
+
+template <class T>
+inline
+ComPtr<T>::operator int ComPtr<T>::ConversionToBool::*() const
+{
+ return ptr != NULL ? &ConversionToBool::dummy : NULL;
+}
template <class S, class T>
bgstack15