r3287 - trunk/libmutil/include/libmutil
erik at minisip.org
erik at minisip.org
Tue May 22 19:50:30 CEST 2007
Author: erik
Date: 2007-05-22 19:50:30 +0200 (Tue, 22 May 2007)
New Revision: 3287
Modified:
trunk/libmutil/include/libmutil/MemObject.h
Log:
* Change return type of MRef::operator= from void to "MRef&".
This enables us to do things such as
if ((ref=ptr).isNull()){...}
or
r1=r2=r3;
This is what you expect to be able to do.
Modified: trunk/libmutil/include/libmutil/MemObject.h
===================================================================
--- trunk/libmutil/include/libmutil/MemObject.h 2007-05-22 14:53:46 UTC (rev 3286)
+++ trunk/libmutil/include/libmutil/MemObject.h 2007-05-22 17:50:30 UTC (rev 3287)
@@ -242,7 +242,7 @@
that is why first we decrease, then copy "o", then increase
the counter.
*/
- inline void operator=(const OPType o);
+ inline MRef<OPType>& operator=(const OPType o);
/**
Assign operator overloaded (copying an exhisting MRef)
@@ -250,7 +250,7 @@
that is why first we decrease, then copy "o", then increase
the counter.
*/
- inline void operator=(const MRef<OPType> &r);
+ inline MRef<OPType>& operator=(const MRef<OPType> &r);
/**
Overload the comparison operator (between MRefs).
@@ -368,17 +368,19 @@
}
template<class OPType>
-void MRef<OPType>::operator=(const OPType o){
+MRef<OPType>& MRef<OPType>::operator=(const OPType o){
decrease();
setPointer( o );
increase();
+ return *this;
}
template<class OPType>
-void MRef<OPType>::operator=(const MRef<OPType> &r){
+MRef<OPType>& MRef<OPType>::operator=(const MRef<OPType> &r){
decrease();
setPointer( r.getPointer() );
increase();
+ return *this;
}
template<class OPType>
More information about the Minisip-devel
mailing list