diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-11-06 07:32:02 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-11-06 07:32:02 +0000 |
commit | ce56884c340c40aaf5c90d736a404208ef486943 (patch) | |
tree | 7d9e536587ab896c22fd310607fefde2be7a06c3 /Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh | |
parent | f0b25fb4bbeafb31d6b33db6763974da38e21cfc (diff) |
harfbuzz-2.1.1
git-svn-id: svn://tug.org/texlive/trunk@49090 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh index 3d8a1ae6cce..25a24f05cb4 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh @@ -87,7 +87,7 @@ template <typename Type> static inline Type& Crap (void) { static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); Type *obj = reinterpret_cast<Type *> (_hb_CrapPool); - *obj = Null(Type); + memcpy (obj, &Null(Type), sizeof (*obj)); return *obj; } #define Crap(Type) Crap<typename hb_remove_const<typename hb_remove_reference<Type>::value>::value>() @@ -103,4 +103,28 @@ 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) const { return get (); } + inline T & operator * (void) const { return *get (); } + inline T ** operator & (void) const { return &v; } + /* Only auto-cast to const types. */ + template <typename C> inline operator const C * (void) const { return get (); } + inline operator const char * (void) const { return (const char *) get (); } + inline T * get (void) const { return v ? v : const_cast<T *> (&Null(T)); } + inline T * get_raw (void) const { return v; } + + T *v; +}; + + #endif /* HB_NULL_HH */ |