10#ifndef MRC_ENABLE_EXCEPTIONS
11# ifdef __cpp_exceptions
12# define MRC_ENABLE_EXCEPTIONS 1
14# define MRC_ENABLE_EXCEPTIONS 0
20 #if MRC_ENABLE_EXCEPTIONS
21 #define MRBINDC_THROW(message_, ...) throw std::runtime_error(+(message_))
24 #define MRBINDC_THROW(message_, ...) (mrbindc_details::ThrowWithExceptionsDisabled(message_), ((__VA_ARGS__ (*)())0)())
29 #define MRBINDC_CLASSARG_DEF_CTOR(param_, ...) param_##_pass_by == MR_PassBy_DefaultConstruct ? (param_ ? MRBINDC_THROW("Expected a null pointer to be passed to `" #param_ " because `MR_PassBy_DefaultConstruct` was used.", __VA_ARGS__) : __VA_ARGS__{}) :
30 #define MRBINDC_CLASSARG_COPY(param_, cpp_type_without_wrapper_, ...) param_##_pass_by == MR_PassBy_Copy ? __VA_ARGS__(*(MRBINDC_IDENTITY cpp_type_without_wrapper_ *)param_) :
31 #define MRBINDC_CLASSARG_MOVE(param_, cpp_type_without_wrapper_, ...) param_##_pass_by == MR_PassBy_Move ? __VA_ARGS__(std::move(*(MRBINDC_IDENTITY cpp_type_without_wrapper_ *)param_)) :
32 #define MRBINDC_CLASSARG_DEF_ARG(param_, enum_constant_, default_arg_, ...) param_##_pass_by == enum_constant_ ? (param_ ? MRBINDC_THROW("Expected a null pointer to be passed to `" #param_ " because `" #enum_constant_ "` was used.", __VA_ARGS__) : __VA_ARGS__(default_arg_)) :
33 #define MRBINDC_CLASSARG_NO_DEF_ARG(param_, enum_constant_, ...) param_##_pass_by == enum_constant_ ? MRBINDC_THROW("Function parameter `" #param_ " doesn't support `" #enum_constant_ "`.", __VA_ARGS__) :
34 #define MRBINDC_CLASSARG_END(param_, ...) true ? MRBINDC_THROW("Invalid `MR_PassBy` enum value specified for function parameter `" #param_ ".", __VA_ARGS__) : ((__VA_ARGS__ (*)())0)()
58 #define MRBINDC_CLASSARG_GUARD(param_, ...) mrbindc_details::ClassArgGuard<__VA_ARGS__> _classarg_guard_##param_((__VA_ARGS__ *)param_, param_##_pass_by)
61 template <
typename T>
constexpr T &
unmove(T &&value) {
return static_cast<T &
>(value);}
65#define MRBINDC_IDENTITY(...) __VA_ARGS__
67#if defined(_MSC_VER) && !defined(__clang__)
68#define MRBINDC_IGNORE_DEPRECATION(...) _Pragma("warning(push)") _Pragma("warning(disable: 4996)") __VA_ARGS__ _Pragma("warning(pop)")
70#define MRBINDC_IGNORE_DEPRECATION(...) _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") __VA_ARGS__ _Pragma("GCC diagnostic pop")
78#ifndef MRBINDC_BIT_CAST
79#if __has_include(<version>)
81#ifdef __cpp_lib_bit_cast
83#define MRBINDC_BIT_CAST(p_type_, ...) std::bit_cast<MRBINDC_IDENTITY p_type_>(__VA_ARGS__)
89#ifndef MRBINDC_BIT_CAST
91#if __has_builtin(__builtin_bit_cast)
92#define MRBINDC_BIT_CAST(p_type_, ...) __builtin_bit_cast(MRBINDC_IDENTITY p_type_, __VA_ARGS__)
98#ifndef MRBINDC_BIT_CAST
100#define MRBINDC_BIT_CAST(p_type_, ...) (MRBINDC_IDENTITY p_type_ (reinterpret_cast<std::add_lvalue_reference_t<std::add_const_t<MRBINDC_IDENTITY p_type_>>>(mrbindc_details::unmove(__VA_ARGS__))))
MR_PassBy
Definition common.h:13
@ MR_PassBy_MoveAndDestroy
Definition common.h:17
@ MR_PassBy_Move
Definition common.h:16
#define MRC_API
Definition include/MRCMisc/exports.h:11
Definition __mrbind_c_details.h:19
constexpr T & unmove(T &&value)
Definition __mrbind_c_details.h:61
MRC_API void ThrowWithExceptionsDisabled(const char *message)
ClassArgGuard(const ClassArgGuard &)=delete
T * ptr
Definition __mrbind_c_details.h:40
~ClassArgGuard()
Definition __mrbind_c_details.h:50
ClassArgGuard & operator=(const ClassArgGuard &)=delete
ClassArgGuard(T *new_ptr, MR_PassBy &pass_by)
Definition __mrbind_c_details.h:41