|
|
|
@ -103,4 +103,32 @@ struct CrapOrNull<const Type> { |
|
|
|
|
#define CrapOrNull(Type) CrapOrNull<Type>::get () |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* hb_nonnull_ptr_t |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
template <typename P> |
|
|
|
|
struct hb_nonnull_ptr_t |
|
|
|
|
{ |
|
|
|
|
typedef typename hb_remove_pointer<P>::value T; |
|
|
|
|
|
|
|
|
|
inline hb_nonnull_ptr_t (T *v_ = nullptr) : v (v_) {} |
|
|
|
|
inline T * operator = (T *v_) { return v = v_; } |
|
|
|
|
inline T * operator -> (void) { return get (); } |
|
|
|
|
inline const T * operator -> (void) const { return get (); } |
|
|
|
|
inline T & operator * (void) { return *get (); } |
|
|
|
|
inline const T & operator * (void) const { return *get (); } |
|
|
|
|
inline T ** operator & (void) { return &v; } |
|
|
|
|
inline const T ** operator & (void) const { return &v; } |
|
|
|
|
inline operator T * (void) { return get (); } |
|
|
|
|
inline operator const T * (void) const { return get (); } |
|
|
|
|
inline T * get (void) { return v ? v : const_cast<T *> (&Null(T)); } |
|
|
|
|
inline const T * get (void) const { return v ? v : const_cast<T *> (&Null(T)); } |
|
|
|
|
inline T * get_raw (void) { return v; } |
|
|
|
|
inline const T * get_raw (void) const { return v; } |
|
|
|
|
|
|
|
|
|
T *v; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* HB_NULL_HH */ |
|
|
|
|