Skip to content

Commit a8cd11b

Browse files
committed
std::launder
1 parent 5d5355f commit a8cd11b

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

include/momo/UserSettings.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@
201201

202202
#define MOMO_COPY_MEMORY(dst, src, size) std::memcpy(dst, src, size)
203203

204-
#define MOMO_CAST_POINTER(ResObject, ptr, isWithinLifetime, isSingleObject) reinterpret_cast<ResObject*>(ptr)
205-
//#define MOMO_CAST_POINTER(ResObject, ptr, isWithinLifetime, isSingleObject) \
206-
// ((isWithinLifetime) ? std::launder(reinterpret_cast<ResObject*>(ptr)) : reinterpret_cast<ResObject*>(ptr))
207-
//#if !defined(__cpp_lib_launder) || (defined(_MSC_VER) && defined(_M_CEE))
208-
//# undef MOMO_CAST_POINTER
209-
//# define MOMO_CAST_POINTER(ResObject, ptr, isWithinLifetime, isSingleObject) reinterpret_cast<ResObject*>(ptr)
210-
//#endif
204+
#define MOMO_CAST_POINTER(ResObject, ptr, isWithinLifetime, isSingleObject) \
205+
((isWithinLifetime && isSingleObject) ? std::launder(reinterpret_cast<ResObject*>(ptr)) \
206+
: reinterpret_cast<ResObject*>(ptr))
207+
#if !defined(__cpp_lib_launder) || (defined(_MSC_VER) && defined(_M_CEE))
208+
# undef MOMO_CAST_POINTER
209+
# define MOMO_CAST_POINTER(ResObject, ptr, isWithinLifetime, isSingleObject) reinterpret_cast<ResObject*>(ptr)
210+
#endif
211211

212212
#ifdef __cpp_constexpr
213213
# define MOMO_CONSTEXPR_VERSION __cpp_constexpr

0 commit comments

Comments
 (0)