LRDE Tiger Compiler
1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
|
#include <ref.hh>
Public Types | |
typedef std::shared_ptr< T > | super_type |
The parent class. | |
typedef T | element_type |
The type pointed to. |
Public Member Functions | |
template<typename U > | |
bool | is_a () const |
Test fellowship. Return true if the reference points to an object which is really of the specified type. | |
Constructors & Destructor. | |
template<typename U > | |
ref (const ref< U > &other) | |
Construct a new reference to the value pointed to by other. The new reference shares the property of the object with other. | |
ref (const ref< T > &other) | |
Copy constructor. | |
ref (T *p=nullptr) | |
Construct a counted reference to a newly allocated object. The new reference takes the property of the object pointed to by p. If p is null, then the reference is invalid and must be reset() before use. | |
~ref () | |
Destroy a reference. The object pointed to is destroyed iff it is not referenced anymore. | |
Equality operators. | |
bool | operator== (const T *p) const |
Reference comparison. Returns true if this points to p. | |
bool | operator!= (const T *p) const |
Reference comparison. Returns false if this points to p. | |
Casts. | |
template<typename U > | |
ref< U > | cast () const |
Cast the reference. Return a new reference, possibly throwing an exception if the dynamic_cast is invalid. | |
template<typename U > | |
ref< U > | unsafe_cast () const |
Cast the reference (unsafe). Return a new reference, possibly a null reference if the dynamic_cast is invalid. |
A std::shared_ptr wrapper.
Compared to its super type, this implementation provides cast operators, and implicit constructors.
typedef T misc::ref< T >::element_type |
The type pointed to.
typedef std::shared_ptr<T> misc::ref< T >::super_type |
The parent class.
Construct a new reference to the value pointed to by other. The new reference shares the property of the object with other.
Copy constructor.
Although the implementation is subsumed by the previous, more generic one, the C++ standard still mandates this specific signature. Otherwise, the compiler will provide a default implementation, which is of course wrong. Note that the same applies for the assignment operator.
Construct a counted reference to a newly allocated object. The new reference takes the property of the object pointed to by p. If p is null, then the reference is invalid and must be reset()
before use.
Destroy a reference. The object pointed to is destroyed iff it is not referenced anymore.
Cast the reference. Return a new reference, possibly throwing an exception if the dynamic_cast is invalid.
Test fellowship. Return true if the reference points to an object which is really of the specified type.
bool misc::ref< T >::operator!= | ( | const T * | p | ) | const |
Reference comparison. Returns false if this points to p.
bool misc::ref< T >::operator== | ( | const T * | p | ) | const |
Reference comparison. Returns true if this points to p.
Cast the reference (unsafe). Return a new reference, possibly a null reference if the dynamic_cast is invalid.