[vlc-devel] commit: Skins2: Add (and use) template parameter typedefs so that they might be used, say, as function return types. The next commit needs this. (JP Dinger )
git version control
git at videolan.org
Sat Dec 5 22:35:10 CET 2009
vlc | branch: master | JP Dinger <jpd at videolan.org> | Sat Nov 21 19:22:38 2009 +0100| [a7b6b23deeb165e614409dd60012d114cd047eef] | committer: JP Dinger
Skins2: Add (and use) template parameter typedefs so that they might be used, say, as function return types. The next commit needs this.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a7b6b23deeb165e614409dd60012d114cd047eef
---
modules/gui/skins2/utils/pointer.hpp | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/modules/gui/skins2/utils/pointer.hpp b/modules/gui/skins2/utils/pointer.hpp
index 0c17144..4d2aa29 100644
--- a/modules/gui/skins2/utils/pointer.hpp
+++ b/modules/gui/skins2/utils/pointer.hpp
@@ -30,14 +30,17 @@
template <class T> class CountedPtr
{
public:
- explicit CountedPtr( T *pPtr = 0 ): m_pCounter( 0 )
+ typedef T *pointer;
+ typedef T &reference;
+
+ explicit CountedPtr( pointer pPtr = 0 ): m_pCounter( 0 )
{
if( pPtr ) m_pCounter = new Counter( pPtr );
}
~CountedPtr() { release(); }
- CountedPtr(const CountedPtr &rPtr ) { acquire( rPtr.m_pCounter ); }
+ CountedPtr( const CountedPtr &rPtr ) { acquire( rPtr.m_pCounter ); }
CountedPtr &operator=( const CountedPtr &rPtr )
{
@@ -49,11 +52,11 @@ public:
return *this;
}
- T &operator*() const { return *m_pCounter->m_pPtr; }
-
- T *operator->() const {return m_pCounter->m_pPtr; }
+ // XXX Somebody explain why operator* and operator-> don't use get()
+ reference operator*() const { return *m_pCounter->m_pPtr; }
+ pointer operator->() const { return m_pCounter->m_pPtr; }
- T *get() const { return m_pCounter ? m_pCounter->m_pPtr : 0; }
+ pointer get() const { return m_pCounter ? m_pCounter->m_pPtr : 0; }
bool unique() const
{
@@ -63,9 +66,9 @@ public:
private:
struct Counter
{
- Counter( T* pPtr = 0, unsigned int c = 1 )
+ Counter( pointer pPtr = 0, unsigned int c = 1 )
: m_pPtr( pPtr ), m_count( c ) { }
- T* m_pPtr;
+ pointer m_pPtr;
unsigned int m_count;
} *m_pCounter;
More information about the vlc-devel
mailing list