Commit cd66246a authored by Philip Chimento's avatar Philip Chimento 🚮

arg: Explicitly enable pointer and non-pointer inlines

Based on feedback from Marco, we should put this back in. The
non-pointer overload should be explicitly disabled for pointers, and the
T* overload does not match pointer-to-pointer (e.g. void**)
automatically.
parent f7b88529
...@@ -148,14 +148,17 @@ GJS_USE inline decltype(auto) gjs_arg_member<int, GI_TYPE_TAG_INTERFACE>( ...@@ -148,14 +148,17 @@ GJS_USE inline decltype(auto) gjs_arg_member<int, GI_TYPE_TAG_INTERFACE>(
} }
template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID> template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID>
inline void gjs_arg_set(GIArgument* arg, T v) { inline std::enable_if_t<!std::is_pointer_v<T>> gjs_arg_set(GIArgument* arg,
T v) {
gjs_arg_member<T, TAG>(arg) = v; gjs_arg_member<T, TAG>(arg) = v;
} }
template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID> template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID>
inline void gjs_arg_set(GIArgument* arg, T* v) { inline std::enable_if_t<std::is_pointer_v<T>> gjs_arg_set(GIArgument* arg,
using NonconstT = std::remove_const_t<T>; T v) {
gjs_arg_member<NonconstT*, TAG>(arg) = const_cast<NonconstT*>(v); using NonconstPtrT =
std::add_pointer_t<std::remove_const_t<std::remove_pointer_t<T>>>;
gjs_arg_member<NonconstPtrT, TAG>(arg) = const_cast<NonconstPtrT>(v);
} }
// Store function pointers as void*. It is a requirement of GLib that your // Store function pointers as void*. It is a requirement of GLib that your
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment