Add CrapOrNull

This commit is contained in:
Behdad Esfahbod 2018-05-30 16:25:46 -07:00
parent 251cc977e9
commit d600e844aa
1 changed files with 11 additions and 0 deletions

View File

@ -605,6 +605,17 @@ static inline Type& Crap (void) {
}
#define Crap(Type) Crap<Type>()
template <typename Type>
struct CrapOrNull {
static inline Type & get (void) { return Crap(Type); }
};
template <typename Type>
struct CrapOrNull<const Type> {
static inline Type const & get (void) { return Null(Type); }
};
#define CrapOrNull(Type) CrapOrNull<Type>::get ()
/* arrays and maps */