Panda3D
Public Types | Public Member Functions | List of all members
ConstPointerTo< T > Class Template Reference

A ConstPointerTo is similar to a PointerTo, except it keeps a const pointer to the thing. More...

#include "pointerTo.h"

Inheritance diagram for ConstPointerTo< T >:
PointerToBase< T > PointerToVoid MemoryBase

Public Types

typedef PointerToBase< T >::To To
 
- Public Types inherited from PointerToBase< T >
typedef T To
 

Public Member Functions

 ConstPointerTo (const To *ptr=(const To *) NULL)
 
 ConstPointerTo (const PointerTo< T > &copy)
 
 ConstPointerTo (const ConstPointerTo< T > &copy)
 
const T *& cheat ()
 Returns a reference to the underlying pointer. More...
 
void clear ()
 
 operator const T * () const
 We also have the typecast operator to automatically convert ConstPointerTo's to the required kind of actual pointer. More...
 
const To & operator* () const
 
const To * operator-> () const
 
ConstPointerTo< T > & operator= (const To *ptr)
 
ConstPointerTo< T > & operator= (const PointerTo< T > &copy)
 
ConstPointerTo< T > & operator= (const ConstPointerTo< T > &copy)
 
const To * p () const
 Returns an ordinary pointer instead of a ConstPointerTo. More...
 
- Public Member Functions inherited from PointerToBase< T >
void clear ()
 A convenient way to set the PointerTo object to NULL. More...
 
void output (ostream &out) const
 A handy function to output PointerTo's as a hex pointer followed by a reference count. More...
 
- Public Member Functions inherited from PointerToVoid
size_t get_hash () const
 
bool is_null () const
 Returns true if the PointerTo is a NULL pointer, false otherwise. More...
 
bool operator!= (const PointerToVoid &other) const
 
bool operator< (const void *other) const
 
bool operator< (const PointerToVoid &other) const
 
bool operator== (const PointerToVoid &other) const
 
void swap (PointerToVoid &other) NOEXCEPT
 Swaps the contents of this PointerTo with the other, without touching the reference counts. More...
 

Detailed Description

template<class T>
class ConstPointerTo< T >

A ConstPointerTo is similar to a PointerTo, except it keeps a const pointer to the thing.

(Actually, it keeps a non-const pointer, because it must be allowed to adjust the reference counts, and it must be able to delete it when the reference count goes to zero. But it presents only a const pointer to the outside world.)

Notice that a PointerTo may be assigned to a ConstPointerTo, but a ConstPointerTo may not be assigned to a PointerTo.

Definition at line 144 of file pointerTo.h.

Member Function Documentation

◆ cheat()

template<class T >
const T *& ConstPointerTo< T >::cheat ( )
inline

Returns a reference to the underlying pointer.

This is a very unsafe method. It's only used by some interrogate code. If you think this method might be useful to you, you're probably wrong.

Promise me you won't use this, okay?

Definition at line 311 of file pointerTo.I.

Referenced by ConstPointerTo< T >::operator const T *().

◆ operator const T *()

template<class T >
ConstPointerTo< T >::operator const T * ( ) const
inline

We also have the typecast operator to automatically convert ConstPointerTo's to the required kind of actual pointer.

This introduces ambiguities which the compiler will resolve one way or the other, but we don't care which way it goes because either will be correct.

Definition at line 295 of file pointerTo.I.

References ConstPointerTo< T >::cheat().

◆ p()

template<class T >
const ConstPointerTo< T >::To * ConstPointerTo< T >::p ( ) const
inline

Returns an ordinary pointer instead of a ConstPointerTo.

Useful to work around compiler problems, particularly for implicit upcasts.

Definition at line 324 of file pointerTo.I.

Referenced by ConstPointerTo< FileReference >::cheat().


The documentation for this class was generated from the following files: