Author: wyoung
Date: Wed Nov 28 05:01:45 2007
New Revision: 1901
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1901&view=rev
Log:
- Removed RefCountedPointer::operator==() Found a better way
- Changed operator bool() into operator void*: this provides some of the
"safe bool" ideas kicked around on the mailing list, and gives
operator==() and operator!=() for free
- Added RefCountedPointer::raw() overloads (one const, the other not)
for when you need the raw internal pointer. Tried to avoid this and
previous one by adding operator T*() and operator const T*() but it
seemed to cause the compiler a lot of confusion.
Modified:
trunk/lib/refcounted.h
Modified: trunk/lib/refcounted.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/refcounted.h?rev=1901&r1=1900&r2=1901&view=diff
==============================================================================
--- trunk/lib/refcounted.h (original)
+++ trunk/lib/refcounted.h Wed Nov 28 05:01:45 2007
@@ -162,13 +162,6 @@
return *this;
}
- /// \brief Returns true if other refcounted pointer's internal
- /// data pointer is the same as this one's.
- bool operator ==(const ThisType& rhs)
- {
- return rhs->counted_ == counted_;
- }
-
/// \brief Access the object through the smart pointer
T* operator ->() const
{
@@ -181,16 +174,34 @@
return *counted_;
}
- /// \brief Returns true if this object can be dereferenced.
- operator bool() const
- {
- return counted_ != 0;
- }
-
- /// \brief Returns true if this object cannot be safely dereferenced
- bool operator !() const
- {
- return counted_ == 0;
+ /// \brief Returns the internal raw pointer converted to void*
+ ///
+ /// This isn't intended to be used directly; if you need the
+ /// pointer, call raw() instead. It's used internally by the
+ /// compiler to implement operators bool, ==, and !=
+ operator void*()
+ {
+ return counted_;
+ }
+
+ /// \brief Returns the internal raw pointer converted to const void*
+ ///
+ /// \see comments for operator void*()
+ operator const void*() const
+ {
+ return counted_;
+ }
+
+ /// \brief Return the raw pointer in T* context
+ T* raw()
+ {
+ return counted_;
+ }
+
+ /// \brief Return the raw pointer when used in const T* context
+ const T* raw() const
+ {
+ return counted_;
}
private:
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits