summaryrefslogtreecommitdiff
path: root/cpp/include
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/include')
-rw-r--r--cpp/include/Ice/Handle.h36
-rw-r--r--cpp/include/IceUtil/Handle.h47
2 files changed, 43 insertions, 40 deletions
diff --git a/cpp/include/Ice/Handle.h b/cpp/include/Ice/Handle.h
index b66a3023079..b94cd81e079 100644
--- a/cpp/include/Ice/Handle.h
+++ b/cpp/include/Ice/Handle.h
@@ -30,13 +30,14 @@ namespace IceInternal
{
template<typename T>
-class Handle
+class Handle : public ::IceUtil::HandleBase<T>
{
public:
- Handle(T* p = 0) :
- _ptr(p)
+ Handle(T* p = 0)
{
+ _ptr = p;
+
if (_ptr)
{
incRef(_ptr);
@@ -44,9 +45,10 @@ public:
}
template<typename Y>
- Handle(const Handle<Y>& r) :
- _ptr(r._ptr)
+ Handle(const Handle<Y>& r)
{
+ _ptr = r._ptr;
+
if (_ptr)
{
incRef(_ptr);
@@ -54,9 +56,10 @@ public:
}
template<typename Y>
- Handle(const ::IceUtil::Handle<Y>& r) :
- _ptr(r._ptr)
+ Handle(const ::IceUtil::Handle<Y>& r)
{
+ _ptr = r._ptr;
+
if (_ptr)
{
incRef(_ptr);
@@ -65,12 +68,13 @@ public:
#ifdef WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here???
template<>
- Handle(const Handle<T>& r) :
+ Handle(const Handle<T>& r)
#else
- Handle(const Handle& r) :
+ Handle(const Handle& r)
#endif
- _ptr(r._ptr)
{
+ _ptr = r._ptr;
+
if (_ptr)
{
incRef(_ptr);
@@ -169,7 +173,7 @@ public:
}
template<class Y>
- static Handle dynamicCast(const Handle<Y>& r)
+ static Handle dynamicCast(const ::IceUtil::HandleBase<Y>& r)
{
return Handle(dynamic_cast<T*>(r._ptr));
}
@@ -179,16 +183,6 @@ public:
{
return Handle(dynamic_cast<T*>(p));
}
-
- typedef T element_type;
-
- T* get() const { return _ptr; }
- T* operator->() const { return _ptr; }
- operator bool() const { return _ptr ? true : false; }
-
- void swap(Handle& other) { std::swap(_ptr, other._ptr); }
-
- T* _ptr;
};
template<typename T, typename U>
diff --git a/cpp/include/IceUtil/Handle.h b/cpp/include/IceUtil/Handle.h
index 5def4862568..732fbe03606 100644
--- a/cpp/include/IceUtil/Handle.h
+++ b/cpp/include/IceUtil/Handle.h
@@ -22,13 +22,30 @@ namespace IceUtil
{
template<typename T>
-class Handle
+class HandleBase
+{
+public:
+
+ typedef T element_type;
+
+ T* get() const { return _ptr; }
+ T* operator->() const { return _ptr; }
+ operator bool() const { return _ptr ? true : false; }
+
+ void swap(HandleBase& other) { std::swap(_ptr, other._ptr); }
+
+ T* _ptr;
+};
+
+template<typename T>
+class Handle : public HandleBase<T>
{
public:
- Handle(T* p = 0) :
- _ptr(p)
+ Handle(T* p = 0)
{
+ _ptr = p;
+
if (_ptr)
{
_ptr->__incRef();
@@ -36,9 +53,10 @@ public:
}
template<typename Y>
- Handle(const Handle<Y>& r) :
- _ptr(r._ptr)
+ Handle(const Handle<Y>& r)
{
+ _ptr = r._ptr;
+
if (_ptr)
{
_ptr->__incRef();
@@ -47,12 +65,13 @@ public:
#ifdef WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here???
template<>
- Handle(const Handle<T>& r) :
+ Handle(const Handle<T>& r)
#else
- Handle(const Handle& r) :
+ Handle(const Handle& r)
#endif
- _ptr(r._ptr)
{
+ _ptr = r._ptr;
+
if (_ptr)
{
_ptr->__incRef();
@@ -131,7 +150,7 @@ public:
}
template<class Y>
- static Handle dynamicCast(const Handle<Y>& r)
+ static Handle dynamicCast(const HandleBase<Y>& r)
{
return Handle(dynamic_cast<T*>(r._ptr));
}
@@ -141,16 +160,6 @@ public:
{
return Handle(dynamic_cast<T*>(p));
}
-
- typedef T element_type;
-
- T* get() const { return _ptr; }
- T* operator->() const { return _ptr; }
- operator bool() const { return _ptr ? true : false; }
-
- void swap(Handle& other) { std::swap(_ptr, other._ptr); }
-
- T* _ptr;
};
template<typename T, typename U>